Task: | Kortit |
Sender: | Yytsi |
Submission time: | 2020-09-27 00:26:06 +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 <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while (t--) { int n; cin>>n; int tb[105] = {0}; for (int i = 0; i < n / 2; i++) { int c; cin>>c; tb[c] = 1; } deque<int> me, p; for (int i = 1; i <= n; i++) (tb[i] == 1 ? me : p).push_back(i); int res = 0; for (int i = 0; i < n / 2; i++) { int mv = p.back(); p.pop_back(); if (me.back() > mv) { res++; me.pop_back(); } else me.pop_front(); } cout<<res<<"\n"; } }