Submission #423885

# Submission time Handle Problem Language Result Execution time Memory
423885 2021-06-11T13:48:08 Z oolimry Table Tennis (info1cup20_tabletennis) C++17
34 / 100
3000 ms 171860 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;

int n, K;
vector<int> arr;

unordered_map<int,int> M;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> K;
	n += K;
	arr.resize(n);
	for(int i = 0;i < n;i++) cin >> arr[i];
	
	
	for(int i = K+1;i <= n-K-1;i++){
		int other = n-i;
		for(int j = max(other-600,0);j <= min(n-1, other+600);j++){
			M[arr[i]+arr[j]]++;
		}
	}
	
	for(int s = 0;s <= K+1;s++){
		for(int e = n-1;e >= n-K-1;e--){
			if(s + (n-1)-e > K) continue;
			
			int str = arr[s]+arr[e];
			
			vector<int> ans;
			for(int i = s;i < K+1;i++){
				auto it = lower_bound(all(arr), str-arr[i]);
				if(it == arr.end()) continue;
				if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
			}
			
			for(int i = n-K;i <= e;i++){
				auto it = lower_bound(all(arr), str-arr[i]);
				if(it == arr.end()) continue;
				if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
			}
			
			if(sz(ans) + M[str] == n-K){
				ans.clear();
				
				for(int i = s;i <= e;i++){
					auto it = lower_bound(all(arr), str-arr[i]);
					if(it == arr.end()) continue;
					if(*it == str-arr[i] and arr[i] != str-arr[i]) ans.push_back(arr[i]);
				}
				
				for(int x : ans) cout << x << " ";
				return 0;
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 242 ms 21036 KB Output is correct
2 Correct 39 ms 452 KB Output is correct
3 Correct 338 ms 26544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 437 ms 1004 KB Output is correct
2 Execution timed out 3055 ms 169988 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 81532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 10 ms 588 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 45 ms 904 KB Output is correct
3 Correct 617 ms 40352 KB Output is correct
4 Correct 384 ms 27896 KB Output is correct
5 Correct 43 ms 952 KB Output is correct
6 Correct 46 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Execution timed out 3078 ms 171860 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Execution timed out 3035 ms 169820 KB Time limit exceeded
3 Halted 0 ms 0 KB -