Task: | Kortit |
Sender: | mango_lassi |
Submission time: | 2020-09-27 21:04:16 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 23 |
#2 | ACCEPTED | 77 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
Code
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { int n; cin >> n; int h = n/2; vector<int> vals(h); for (int i = 0; i < h; ++i) cin >> vals[i]; sort(vals.begin(), vals.end()); int res = 0, cur = 0, j = 1; for (auto i : vals) { while(i > j) { ++j; ++cur; } ++j; if (cur > 0) { --cur; ++res; } } cout << res << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; for (int ti = 0; ti < t; ++ti) solve(); }