Submission #521293

# Submission time Handle Problem Language Result Execution time Memory
521293 2022-02-01T13:48:01 Z Baytoro Table Tennis (info1cup20_tabletennis) C++17
87 / 100
3000 ms 4420 KB
#include <bits/stdc++.h>
using namespace std;
#define Baytoro_MayrambekovOrz void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
int n,k;
vector<int> vec,ans;
bool check(int x){
	int i;
	int cnt=0;
	ans.clear();
	int r=n+k-1;
	
	for(i=0;i<r && cnt<n/2;i++){
		while(r>i && vec[i]+vec[r]>x)
			r--;
		if(r>i && vec[i]+vec[r]==x){
			cnt++;
			ans.pb(vec[i]);
			ans.pb(vec[r]);
		}
	}
	
	return n/2==cnt;
}
int a,b,c,m,j,x,y,cnt=0,sum=0,res=0;
Baytoro_MayrambekovOrz{
	int i;
	cin>>n>>k;
	vec.resize(n+k);
	for(i=0;i<n+k;i++){
		cin>>vec[i];
	}
	map<int,bool> used;
	for(i=0;i<=min(k+2,n+k);i++){
		for(j=max(0ll,n-2);j<n+k;j++){
			if(used[vec[i]+vec[j]])
				continue;
			used[vec[i]+vec[j]]=1;
			if(check(vec[i]+vec[j])){
				sort(all(ans));
				for(auto it: ans)
					cout<<it<<' ';
				return;
			}
		}
	}
}
main(){
	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Compilation message

tabletennis.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 848 KB Output is correct
2 Correct 35 ms 4288 KB Output is correct
3 Correct 31 ms 4156 KB Output is correct
4 Correct 39 ms 4168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4188 KB Output is correct
2 Correct 29 ms 4208 KB Output is correct
3 Correct 33 ms 4292 KB Output is correct
4 Correct 32 ms 4156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 5 ms 844 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 274 ms 4420 KB Output is correct
3 Correct 32 ms 4156 KB Output is correct
4 Correct 68 ms 4168 KB Output is correct
5 Correct 34 ms 4172 KB Output is correct
6 Correct 40 ms 4300 KB Output is correct
7 Correct 65 ms 4284 KB Output is correct
8 Correct 35 ms 4280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 3060 ms 1860 KB Time limit exceeded
3 Halted 0 ms 0 KB -