codeforces VK Cup 2012 Qualification Round 1, problem: (A) Next Round:
http://codeforces.com/problemset/problem/158/A
codeforces VK Cup 2012 Qualification Round 1, problem: (A) Next Round solution: http://ideone.com/e9JrhL
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n, k, a[55];
scanf("%d%d", &n, &k);
for(int i=0; i<n; i++) scanf("%d", &a[i]);
if(a[k-1]>0) {
for(int i=k; i<n; i++) {
if(a[i]==a[k-1]) k++;
else break;
}
}
else {
for(int i=k-1; i>=0; i--) {
if(a[i]==0) k--;
else break;
}
}
printf("%d\n", k);
return 0;
}
No comments:
Post a Comment