CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:rasastusni
Submission time:2020-09-26 13:42:18 +0300
Language:C++17
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 main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i) {
		int n;
		cin >> n;
		set<int> my_c;
		for (int a = 0; a < n / 2; ++a) {
			int c;
			cin >> c;
			my_c.insert(c);
		}
		set<int> opp_c;
		for (int a = 0; a < n; ++a) {
			if (my_c.find(a + 1) == my_c.end()) {
				opp_c.insert(a + 1);
			}
		}
		int w = 0;
		for (auto it = opp_c.rbegin(); it != opp_c.rend(); ++it) {
			auto beat = my_c.upper_bound(*it);
			if (beat != my_c.end()) {
				++w;
				my_c.erase(beat);
			} else {
				my_c.erase(my_c.begin());
			}
		}
		cout << w << endl;
	}
}

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