CodeForces.158A Next Round (水模拟)
题意分析
校赛水题的英文版,坑点就是要求为正数。
代码总览
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INF 0x3f3f3f3f
#define nmax 200
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
int a[nmax];
int main()
{
//freopen("in.txt","r",stdin);
int n,k;
while(scanf("%d %d",&n,&k)!= EOF){
for(int i = 0; i<n;++i)
scanf("%d",&a[i]);
int tar = a[k-1];
int ans = 0;
for(int i = 0;i<n;++i){
if(a[i] <=0) break;
if(a[i] < tar) break;
if(a[i] >= tar) ans++;
}
printf("%d
",ans);
}
return 0;
}