Code for USACO practice problems
cpp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
403 B

3 years ago
using namespace std;
#include <iostream>
int main() {
int n, k;
cin >> n >> k;
int w;
int a = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j == 0) {
break;
}
if (i == k - 1) {
w = j;
a++;
} else if (i > k - 1) {
if (j == w) {
a++;
} else {
break;
}
} else {
a++;
}
}
cout << a << endl;
}