Task: | Kortit |
Sender: | Ender |
Submission time: | 2020-09-25 18:27:13 +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> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) { int n; cin >> n; vector<int> k(n+1); for(int i = 0; i<(n/2); i++) { int a; cin >> a; k[a]=1; } int ans = 0; priority_queue<int> q; q.push(-1e9); for(int i = 1; i<=n; i++) { if(!k[i]) { q.push(-i); } else if(i>(-q.top())) { q.pop(); ans++; } } cout << ans << "\n"; } return 0; }