Submission #423616

# Submission time Handle Problem Language Result Execution time Memory
423616 2021-06-11T10:30:31 Z errorgorn Table Tennis (info1cup20_tabletennis) C++17
9 / 100
3000 ms 80652 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k;
int arr[160005];
unordered_map<int,int> m;

int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>k;
	rep(x,0,n+k) cin>>arr[x];
	
	int l=n,r=n+k;
	rep(x,0,n){
		l--,r--;
		
		if (r<x) break;
		
		rep(y,max(x+1,l),r+1){
			m[arr[x]+arr[y]]++;
		}
	}
	
	int val;
	for (auto &it:m){
		if (it.se>=n/2) val=it.fi;
	}
	
	vector<int> ans;
	
	r=n+k-1;
	rep(x,0,n){
		while (arr[x]+arr[r]>val) r--;
		if (arr[x]+arr[r]==val){
			ans.pub(arr[x]);
			ans.pub(arr[r]);
			r--;
			
			if (sz(ans)==n) break;
		}
	}
	
	sort(all(ans));
	
	for (auto &it:ans) cout<<it<<" "; cout<<endl;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:65:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   65 |  for (auto &it:ans) cout<<it<<" "; cout<<endl;
      |  ^~~
tabletennis.cpp:65:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   65 |  for (auto &it:ans) cout<<it<<" "; cout<<endl;
      |                                    ^~~~
tabletennis.cpp:53:23: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |   while (arr[x]+arr[r]>val) r--;
      |          ~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 3064 KB Output is correct
2 Correct 48 ms 3212 KB Output is correct
3 Incorrect 24 ms 844 KB Unexpected end of file - int32 expected
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Incorrect 1 ms 588 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 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 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 124 ms 5856 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 844 KB Output is correct
2 Execution timed out 3081 ms 80652 KB Time limit exceeded
3 Halted 0 ms 0 KB -