Task: | Kortit |
Sender: | ollpu |
Submission time: | 2020-09-25 18:05:00 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.01 s | 2 | details |
Code
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; for (int Ti = 0; Ti < T; ++Ti) { int n; cin >> n; int z[n] {}; deque<int> o, t; for (int i = 0; i < n/2; ++i) { int x; cin >> x; x--; o.push_back(x); z[x] = 1; } for (int i = 0; i < n; ++i) { if (!z[i]) { t.push_back(i); } } int res = 0; for (int i = 0; i < n/2; ++i) { if (o.back() > t.back()) { o.pop_back(); res++; } else { o.pop_front(); } t.pop_back(); } cout << res << "\n"; } }