Submission #521294

# Submission time Handle Problem Language Result Execution time Memory
521294 2022-02-01T13:54:36 Z Baytoro Table Tennis (info1cup20_tabletennis) C++17
72 / 100
178 ms 6708 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;
	vector<int> ar;
	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;
			ar.pb(vec[i]+vec[j]);
		}
	}
	random_shuffle(all(ar));
	for (int i = 0; i < min(700ll,(int)ar.size()); i++){
		if(check(ar[i])){
				sort(all(ans));
				for(auto it: ans)
					cout<<it<<' ';
				return;
		}
	}

}
main(){
	ios;
	int T=1;
	//cin>>T;
	while(T--){
		solve();
	}
}


Compilation message

tabletennis.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | 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 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 848 KB Output is correct
2 Correct 34 ms 4296 KB Output is correct
3 Correct 33 ms 4176 KB Output is correct
4 Correct 34 ms 4244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 4264 KB Output is correct
2 Correct 34 ms 4284 KB Output is correct
3 Correct 30 ms 4284 KB Output is correct
4 Correct 35 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 844 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 3 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 332 KB Output is correct
2 Correct 178 ms 4236 KB Output is correct
3 Correct 144 ms 4300 KB Output is correct
4 Correct 44 ms 4196 KB Output is correct
5 Correct 39 ms 4156 KB Output is correct
6 Correct 31 ms 4304 KB Output is correct
7 Correct 93 ms 4236 KB Output is correct
8 Correct 67 ms 4168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 6708 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -