Submission #735074

# Submission time Handle Problem Language Result Execution time Memory
735074 2023-05-03T13:06:40 Z NintsiChkhaidze Table Tennis (info1cup20_tabletennis) C++17
34 / 100
86 ms 4292 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define int long long
using namespace std;

const int N = 2e5+5,inf = 1e9;
int a[N],n,k;
vector <int> v;

void check(int sum){
	v.clear();
	int r = n + k;
	for (int i = 1; i <= n + k; i++){
		while (i < r){
			if (a[i] + a[r] > sum) {
				r--;
				continue;
			}
			break;
		}
		if (i < r && a[i] + a[r] == sum){
			v.pb(a[i]),v.pb(a[r]);
			r--;
		}
	}
	
	if (v.size() == n){
		sort(v.begin(),v.end());
		for (int x: v) cout<<x<<" ";
		cout<<endl;
		exit(0);
	}
	
}
signed main (){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	cin>>n>>k;
	
	for (int i = 1; i <= n+k;i++)
		cin>>a[i];
	
	int mid = (k + 1)/2 + 2;
	
	for (int i = 1; i <= min(mid,n+k); i++){
		int c=0;
		for (int j = n + k; j > i; j--){
			++c;
			if (c > mid) break;
			check(a[i] + a[j]);
		}
	}
}
/*
4 7
1 3 4 5 6 8 9 100 200 431 1234
*/

Compilation message

tabletennis.cpp: In function 'void check(long long int)':
tabletennis.cpp:29:15: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   29 |  if (v.size() == n){
      |      ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 984 KB Output is correct
2 Correct 35 ms 4260 KB Output is correct
3 Correct 34 ms 4220 KB Output is correct
4 Correct 32 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 4184 KB Output is correct
2 Correct 36 ms 4292 KB Output is correct
3 Correct 36 ms 4284 KB Output is correct
4 Correct 31 ms 4220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 212 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -