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 1 9 1 1 2 1 1 的情况,why wrong ???#include<stdio.h> #include<string.h> int main() { int t,i,j,a[101],n,m,s; scanf("%d",&t); while(t--) { s=1; memset(a,0,sizeof(a)); scanf("%d %d",&n,&m); for(i=0;i<n;i++) scanf("%d",&a[i]); for(j=0;j<n;j++) { if(a[j]>a[m]) s++; } for(i=0;i<n;i++) { if(a[i]>a[m] && i>m) { for(j=i+1;j<n;j++) if(a[j]==a[m]) s++; for(j=0;j<m;j++) if(a[j]==a[m]) s++; break; } if(a[i]>a[m] && i<m) { for(j=i+1;j<m;j++) if(a[j]==a[m]) s++; break; } } printf("%d\n",s); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator