Codeforces Round 560 Div. 3 B Polycarp Training
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 | #include <iostream> #include <vector> #include <queue> #include <algorithm> #include<string> #include <cstring> //memset using namespace std; const int MAX = 100000 + 2; int main(void) { vector<int> pq; int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; pq.push_back(a); } sort(pq.begin(), pq.end()); int k = 1; int cnt = 0; for (int i = 0; i < pq.size(); i++) { if (k <= pq[i]) { cnt++; k++; } else continue; } cout << cnt << endl; return 0; } | cs |
출처:https://codeforces.com/contest/1165/problem/B
단순 구현문제였습니다.
벡터로 정렬을 한뒤 쉽게 풀어줄수 있는 문제였습니다.
'알고리즘 > Codeforce' 카테고리의 다른 글
Codeforces Round 560 Div 3 C Good String (0) | 2019.05.18 |
---|---|
Codeforces Round 560 Div. 3 A Remainder (0) | 2019.05.18 |
Codeforces Round 560 Div. 3 D Almost All Divisors (0) | 2019.05.18 |
코드포스 Superhero Transformation (0) | 2019.02.10 |