Task: | Kortit |
Sender: | hltk |
Submission time: | 2020-09-26 16:12:26 +0300 |
Language: | C++ (C++17) |
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 <iostream> #include <vector> int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { int n; std::cin >> n; std::vector<int> v(n); for (int i = 0; i < n / 2; ++i) { int x; std::cin >> x; v[x - 1] = 1; } int s = 0, p = 0; for (int i = 0; i < n; ++i) { p += !v[i]; if (v[i] && p) { s++; p--; } } std::cout << s << '\n'; } }