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 |
纪念1次0MS AC,第一次写出这么短的代码。。嘿嘿Source Code Problem: 1068 User: yzhw Memory: 308K Time: 0MS Language: GCC Result: Accepted Source Code # include <stdio.h> int num; int data[41]; int used[41]; int res[21]; int main() { int testcase,i; scanf("%d",&testcase); for(i=1;i<=testcase;i++) { int j,t1=0,t2=0,tc=0,now=1; scanf("%d",&num); memset(used,0,sizeof(used)); for(j=1;j<=num;j++) { int k; scanf("%d",&t1); for(k=tc+1;k<=tc+t1-t2;k++) data[k]=0; tc+=t1+1-t2; data[tc]=1; t2=t1; } tc=0; while(tc<num) { int k,count=0; for(;data[now]!=1;now++); used[now]=1; tc++; for(k=now-1;used[k]==1;k--); used[k]=1; k=now-k+1; k=k/2; res[tc]=k; now++; } for(j=1;j<num;j++) printf("%d ",res[j]); printf("%d\n",res[num]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator