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 |
0ms水过#include <iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=20+5; const int maxn1=2000; int a[maxn]; int b[maxn]; int s[maxn1]; //圆括号数组 int main() { int t; while(scanf("%d",&t)==1&&t) { int n; while(t--) { memset(s,0,sizeof(s)); scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); //input s[a[i]+i]=2; } for(int i=0;i<n;i++) { int m=a[i]+i; int ans=0; for(int j=m;j>=0;j--) { if(s[j]!=2) ans++; if(!s[j]) { s[j]=1; break; } } b[i]=ans; } for(int i=0;i<n;i++) printf("%d ",b[i]); 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