CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:Gomhog
Submission time:2020-09-25 19:03:45 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED23
#2ACCEPTED77
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F first
#define S second

using 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";
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
1000
2
1
6
2 4 5
...

correct output
0
2
0
2
1
...

user output
0
2
0
2
1
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
70
56 23 58 70 2 57 27 61 47 3 42...

correct output
30
15
1
38
29
...

user output
30
15
1
38
29
...
Truncated