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

Code

#include<iostream>
#include<set>
using namespace std;
int a[101010];
int main() {
int t;
cin >> t;
while(t--){
int n;
cin >> n;
set<int> d1;
set<int> d2;
for(int i = 1; i <= n; i++) a[i] = 0;
for(int i = 0; i < n/2; i++){
int x;
cin >> x;
a[x] = 1;
}
for(int i = 1; i <= n; i++){
if(a[i]) d1.insert(i);
else d2.insert(i);
}
int co = 0;
while(!(d2.empty())){
if(*(d2.rbegin()) < *(d1.rbegin())){
co++;
d2.erase(--d2.end());
d1.erase(--d1.end());
}else{
d2.erase(--d2.end());
d1.erase(d1.begin());
}
}
cout << co << "\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