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 |
0s水过#include <cstdio> #include <cstring> #include <iostream> using namespace std; const int maxn=25; int a[maxn],mius[maxn],res[maxn]; int main(){ int T; scanf("%d",&T); while(T--){ memset(a,0,sizeof(a)); memset(mius,0,sizeof(mius)); memset(res,0,sizeof(res)); int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); if(i==0){ mius[i]=a[i]; } else{ mius[i]=a[i]-a[i-1]; } } for(int i=0;i<n;i++){ if(!a[i]){ res[i]=0; } else{ res[i]=1; for(int j=i;j>=0;j--){ if(mius[j]){ mius[j]--; break; } else{ res[i]++; } } } } for(int i=0;i<n;i++){ printf("%d ",res[i]); } printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator