-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy path158A.cpp
More file actions
50 lines (46 loc) · 670 Bytes
/
158A.cpp
File metadata and controls
50 lines (46 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream>
using namespace std;
int main(){
int n;
int k;
int count;
cin>>n;
cin>>k;
int arr[n];
for(int i = 0; i < n; i++){
cout<<"i:"<<i<<" ";
cin>>arr[i];
}
int quali = 0, m;
if(arr[k-1] == 0){
for(m = k-2; m >= 0; m--){
if(arr[m] > 0){
quali = arr[m];
count = m+1;
cout<<count;
return 0;
}
}
if(quali == 0){
cout<<0;
return 0;
}
}
else{
quali = arr[k-1];
count = k;
}
cout<<endl;
int j = count-2;
while(true){
if(arr[j] == quali){
count++;
}
else{
break;
}
j--;
}
cout<<count;
return 0;
}