Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一次AC,贴上精炼代码#include <iostream> using namespace std; short a[20]; int main(void) { short n,m,i,j,rightCount,tmp1,tmp2=0; cin>>n; while(n--) { cin>>m; tmp2=0; for(i=0;i<m;i++){ cin>>tmp1; a[i] = tmp1 - tmp2; tmp2 = tmp1; rightCount = 1; for(j=i;j>=0;j--){ if(a[j]>0){ a[j]--; break; } else rightCount++; } cout<<rightCount<<" "; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator