Submission #735066

# Submission time Handle Problem Language Result Execution time Memory
735066 2023-05-03T12:59:23 Z NintsiChkhaidze Table Tennis (info1cup20_tabletennis) C++17
34 / 100
764 ms 23116 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define int long long
using namespace std;

const int N = 2e5+5,inf = 1e9;
int a[N],n,k;
map <int,int> mp;
vector <int> v;
void check(int sum){
	mp.clear();
	for (int i= 1; i <= n+k;i++)
		mp[a[i]]++;
	
	v.clear();
	for (int i = 1; i <= n + k; i++){
		if (!mp[a[i]]) continue;
		mp[a[i]]--;
		if (mp[sum - a[i]] > 0) {
			v.pb(a[i]);
			v.pb(sum - a[i]);
			mp[sum - a[i]]--;
			continue;
		}
		mp[a[i]]++;
	}
	
	if (v.size() == n){
		sort(v.begin(),v.end());
		for (int x: v) cout<<x<<" ";
		cout<<endl;
		exit(0);
	}
	
}
signed main (){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	cin>>n>>k;
	
	for (int i = 1; i <= n+k;i++)
		cin>>a[i];
	
	for (int i = 1; i <= min(n,k/2 + 2); i++){
		int c=0;
		for (int j = n + k; j > i; j--){
			++c;
			if (c > k/2 + 2) break;
			check(a[i] + a[j]);
		}
	}
}
/*
4 7
1 3 4 5 6 8 9 100 200 431 1234
*/

Compilation message

tabletennis.cpp: In function 'void check(long long int)':
tabletennis.cpp:30:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |  if (v.size() == n){
      |      ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 4 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2128 KB Output is correct
2 Correct 243 ms 21708 KB Output is correct
3 Correct 218 ms 21732 KB Output is correct
4 Correct 203 ms 23116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 449 ms 21680 KB Output is correct
2 Correct 238 ms 21880 KB Output is correct
3 Correct 620 ms 22996 KB Output is correct
4 Correct 259 ms 23116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 764 ms 340 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -