Submission #735062

# Submission time Handle Problem Language Result Execution time Memory
735062 2023-05-03T12:53:52 Z NintsiChkhaidze Table Tennis (info1cup20_tabletennis) C++17
9 / 100
3000 ms 23184 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; j > i; j--){
			++c;
			if (c > k/2 + 1) break;
			int s = a[i] + a[j];
			check(s);
		}
	}
}

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 Incorrect 3 ms 596 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2300 KB Output is correct
2 Incorrect 178 ms 21680 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 384 ms 23184 KB Output is correct
2 Correct 99 ms 15088 KB Output is correct
3 Incorrect 463 ms 21616 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 115 ms 340 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 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 97 ms 596 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 3068 ms 21616 KB Time limit exceeded
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 3051 ms 21744 KB Time limit exceeded
3 Halted 0 ms 0 KB -