Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- int main() {
- int n, k; cin >> n >> k;
- int old = 10000;
- for (int i = 0; i < n; i++) {
- int tmp; cin >> tmp;
- if (tmp == 0) {
- cout << i << endl;
- return 0;
- }
- if (i < k) {
- old = tmp;
- continue;
- } else {
- if (old != tmp) {
- cout << i << endl;
- return 0;
- }
- }
- }
- cout << n << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement