Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
610 B
1
Indexable
Never
#include <iostream>
#include <Deque>
#include <algorithm>
#include <vector>
#include <unordered_set>
#include <map>
#include <set>
#define endl '\n'

using namespace std;

int main() {
    map<int,int> m;
    auto it = m.begin();
    int n,index;
    int counter=0;
    cin >> n >> index;
    for (int i = 1; i <= n ; ++i) {
        int input=0;
        cin>>input;
        it = m.emplace_hint(it,i,input);
    }

    for (int i = 1; i <= n ; ++i) {
        if(m[i]>= m[index] && m[i]>0)
        {
            counter++;
        }
    }

    cout<<counter<<endl;
    return 0;
}
Leave a Comment