Algorithm

[CodeForce] 158A - Next Round

승우승 2019. 1. 25. 09:20
반응형

문제풀이

영어 해석을 하면 풀수 있는 문제. k번째 선수보다 높은 점수를 가진 사람이 다음라운드로 진출할 수 있다.


소스코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <vector>
using namespace std;
// http://codeforces.com/problemset/problem/158/A
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k,result=0;
    vector<int> scores;
    cin>>n>>k;
    int score;
    for(int i=0; i<n; i++) {
        cin>>score;
        scores.push_back(score);
    }
    for(int i=0; i<n; i++) {
        if(scores[i]>=scores[k-1&& scores[i]>0)   result++;
    }
    cout<<result<<endl;
    return 0;
}
cs


반응형