Submission #708370

# Submission time Handle Problem Language Result Execution time Memory
708370 2023-03-11T16:01:50 Z auslander Table Tennis (info1cup20_tabletennis) C++17
9 / 100
3000 ms 230540 KB
#include <iostream>
#include <map>
#include <iterator>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

const int N = 200005;
ll arr[N];
map<ll, ll>mp;
map<ll, pair<vector<ll>, ll>>r;
int main()
{
	ll i, j, n, k;
	cin >> n >> k;
	for (i = 0; i < n + k; i++)
	{
		cin >> arr[i];
		mp[arr[i]]++;
	}
	sort(arr, arr + k);
	for (i = 0; i < k; i++)
	{
		for (j = n + k - 1; j - i + 1 >= n; j--)
		{
			ll w = arr[i] + arr[j];
			ll q = 1 * (j - i + 1);
			set<ll>st;
			for (int e = i; e <= j; e++)
			{
				int sz = st.size();
				st.insert(arr[e]);
				st.insert(w - arr[e]);
				ll qq = 2;
				if (w - arr[e] == arr[e])
					qq = 1;
				if (st.size() - sz == qq)
				{
					q -= abs(mp[arr[e]] - mp[w - arr[e]]);
				}
			}
			if (q < n)
			{
				mp[arr[j]]--;
				continue;
			}
			st.erase(st.begin(), st.end());
			ll y = n / 2;
			multiset<ll> res;
			for (int e = i; e <= j && y; e++)
			{
				if (mp[arr[e]] && mp[w - arr[e]])
				{
					if (mp[arr[e]] == 1 && arr[e] == w - arr[e])
					{

					}
					else
					{
						res.insert(arr[e]);
						res.insert(w - arr[e]);
						mp[arr[e]]--;
						mp[w - arr[e]]--;
						y--;
					}
				}
			}
			for (set<ll>::iterator it = res.begin(); it != res.end(); it++)
			{
				cout << *it << ' ';
			}
			return 0;
		}
		mp[arr[i]]--;
	}

	return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:39:24: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   39 |     if (st.size() - sz == qq)
      |         ~~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 852 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2728 KB Output is correct
2 Incorrect 294 ms 46008 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 628 ms 66016 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 852 KB Output is correct
2 Incorrect 6 ms 864 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 207 ms 14388 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Execution timed out 3056 ms 221504 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 6092 KB Output is correct
2 Execution timed out 3071 ms 230540 KB Time limit exceeded
3 Halted 0 ms 0 KB -