Task: | Kortit |
Sender: | Gomhog |
Submission time: | 2020-09-25 19:03:45 +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>typedef long long ll;typedef long double ld;#define F first#define S secondusing namespace std;bool ca[101];int main() {ios_base::sync_with_stdio(0);cin.tie(0);int tst;cin>>tst;for (int t=0;t<tst;t++) {int n;cin>>n;for (int i=1;i<=n;i++) ca[i]=false;for (int j=0;j<n/2;j++) {int a;cin>>a;ca[a]=true;}int cnt=0;int dom=0;for (int j=n;j>0;j--) {if (ca[j]) dom++;else {if (dom>0) {dom--;cnt++;}}}cout<<cnt<<"\n";}}