CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:FooBat
Submission time:2020-09-27 07:45:36 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.01 s1, 2details
#20.01 s2details

Code

#include <iostream>
#include <array>
#include <vector>
int main()
{

	int tests, n;
	std::cin >> tests;
	std::array<int, 101> own;
	std::array<int, 101> opponent;

	std::vector<int> results;
	for (int t = 0; t < tests; t++)
	{
		std::cin >> n;
		int x = n / 2;
		int nextCard = 1;
		int oppIdx = 0;
		int ownIdx = 0;
		for (int i = 0; i < x; i++)
		{
			int card;
			std::cin >> card;

			while (card > nextCard)
			{
				opponent[oppIdx++] = nextCard++;
			}
			own[ownIdx++] = nextCard++;
		}
		while (oppIdx < x)
		{
			opponent[oppIdx++] = nextCard++;
		}

		/*
		for (int p = 0; p < x; p++)
			std::cout << "Own: " << own[p] << std::endl;
		for (int p = 0; p < x; p++)
			std::cout << "Opp: " << opponent[p] << std::endl;
		*/

		int playedBig = 0;
		int playedSmall = 0;
		int won = 0;
		for (int i = 0; i < x; i++) 
		{
			int oc = opponent[x - 1 - i];
			int big = own[x - 1 - playedBig];
			if (big > oc) 
			{
				won++;
				playedBig++;
			}
			else 
			{
				if (own[playedSmall++] > oc) 
				{
					won++;
				}
			}
		}
		results.emplace_back(won);
	}
	for (int w : results) 
	{
		std::cout << w << "\n";
	}
	return 0;
}


Test details

Test 1

Group: 1, 2

Verdict:

input
1000
2
1
6
2 4 5
...

correct output
0
2
0
2
1
...

user output
0
2
0
5
3
...
Truncated

Test 2

Group: 2

Verdict:

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

correct output
30
15
1
38
29
...

user output
35
16
1
48
35
...
Truncated