美文网首页编程练习
codeforces 158A (implementation)

codeforces 158A (implementation)

作者: codinRay | 来源:发表于2017-03-30 21:38 被阅读0次

http://codeforces.com/problemset/problem/158/A

生词:
implementation n.贯彻,执行 (实现?)
contestant n.参赛者
excerpt n.摘录,摘要
separate vt.使分开

题面:

求一个数组中比数组第几号位置这个数大的数并为正数的数量。

// codeforces
// 158A
// implementation
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n, k;
    vector<int> s;
    while (cin >> n >> k) {
        int cnt = 0;
        s.resize(n + 1);
        for (int i = 1; i <= n; ++i)
            cin >> s[i];
        int tar = s.at(k);
        for (int i = 1; i <= n; ++i) {
            if (s.at(i) >= tar&&s.at(i) > 0)
                cnt++;
        }
        cout << cnt << '\n';
    }
    return 0;
}

相关文章

网友评论

    本文标题:codeforces 158A (implementation)

    本文链接:https://www.haomeiwen.com/subject/eanpottx.html