CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:ArktinenKarpalo
Submission time:2020-09-25 18:11:15 +0300
Language: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>
#define ll long long
#define ull unsigned long long
#define ld long double

using namespace std;

int k[111], n, t;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> t;
	for(int g=0; g<t; g++) {
		cin >> n;
		for(int i=1; i<=n; i++)
			k[i] = 0;
		int f;
		for(int i=0; i<n/2; i++) {
			cin >> f;
			k[f] = 1;
		}
		int v = n;
		int ans = 0;
		for(int i=0; i<n/2; i++) {
			while(k[v])
				v--;
			int a = 0;
			int b = 0;
			for(int j=1; j<=n; j++) {
				if(a == 0 && k[j])
					a = j;
				if(j > v && k[j])
					b = j;
			}
			if(b>v)
				ans++;
			if(b == 0)
				k[a] = 0;
			else
				k[b] = 0;
			v--;
		}
		cout << ans << "\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
...

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
...