Task: | Kortit |
Sender: | Metabolix |
Submission time: | 2020-09-25 18:21:51 +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 <iostream> #include <algorithm> #include <vector> int testi() { int n; std::cin >> n; std::vector<bool> oma(n); for (int i = 0; i < n/2; ++i) { int k; std::cin >> k; oma[k-1] = true; } int isompia_omia = 0, tulos = 0; for (int i = n; i--;) { if (oma[i]) { isompia_omia += 1; } else if (isompia_omia) { isompia_omia -= 1; tulos += 1; } } return tulos; } int main() { int t; std::cin >> t; for (int i = 0; i < t; ++i) { std::cout << testi() << std::endl; } }