Skip to content

Commit d2aab79

Browse files
committed
Create next_round_158A.cpp
1 parent 9791fff commit d2aab79

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

next_round_158A.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
#include<vector>
3+
using namespace std;
4+
5+
int main() {
6+
int n,k,count = 0;
7+
cin >> n >> k;
8+
vector <int> a(n);
9+
10+
for(int i = 0;i < n;i++){
11+
cin >> a[i];
12+
}
13+
for(int i = 0; i<n; i++) {
14+
15+
if(a.at(i) >= a.at(k-1) && (a.at(i) != 0 || a.at(k-1) != 0)) {
16+
count++;
17+
}
18+
else if(a.at(i) < a.at(k-1)) {
19+
break;
20+
}
21+
}
22+
cout << count << endl;
23+
return 0;
24+
}
25+
26+

0 commit comments

Comments
 (0)