Submission #775678

# Submission time Handle Problem Language Result Execution time Memory
775678 2023-07-06T18:34:21 Z LeaRouse Table Tennis (info1cup20_tabletennis) C++14
72 / 100
3000 ms 206940 KB
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ff first
#define ss second
#define ll long long
using namespace std;
const int MAX=2e5+5;
const ll INF=1e10;
int A[MAX];
int n,k;;
unordered_map<int,int>m;
vector<int>v;
bool res(int suma){
	int ans=0;
	for(int i=0;i<n+k;i++){
		if(!m[A[i]] || ans==n/2)	continue;
		if(A[i]>suma/2)	continue;
		if(m[suma-A[i]]){
			ans++;
			v.push_back(A[i]);
			v.push_back(suma-A[i]);
		}	
	}
	if(ans==n/2)	return true;
	else 	return false;
}

void go(){
		cin>>n>>k;
	for(int i=0;i<(n+k);i++){
		cin>>A[i];
		m[A[i]]++;
	}
	sort(A,A+n+k);
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			int suma=A[i]+A[n+k-1-j];
			if(res(suma)){
				sort(v.begin(),v.end());
				for(auto it:v)	cout<<it<<" ";
				cout << endl;
				break;
			}
			else	v.clear();
		}
		if(v.size()) break; 
	}

}
 
int main(){
	fastio;
	go();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1620 KB Output is correct
2 Correct 85 ms 17608 KB Output is correct
3 Correct 77 ms 17344 KB Output is correct
4 Correct 86 ms 17200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 163 ms 26784 KB Output is correct
2 Correct 89 ms 16864 KB Output is correct
3 Correct 187 ms 28380 KB Output is correct
4 Correct 114 ms 22896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 103 ms 21924 KB Output is correct
3 Correct 2 ms 884 KB Output is correct
4 Correct 85 ms 20836 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
# 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 0 ms 340 KB Output is correct
2 Correct 20 ms 9800 KB Output is correct
3 Correct 6 ms 2608 KB Output is correct
4 Correct 34 ms 11072 KB Output is correct
5 Correct 4 ms 2660 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Execution timed out 3074 ms 204076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2660 KB Output is correct
2 Execution timed out 3077 ms 206940 KB Time limit exceeded
3 Halted 0 ms 0 KB -