Submission #366006

# Submission time Handle Problem Language Result Execution time Memory
366006 2021-02-12T17:46:31 Z keta_tsimakuridze Table Tennis (info1cup20_tabletennis) C++14
0 / 100
68 ms 2540 KB
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,n,k;
vector<int >v,ans;
int a[N];
string s;
 main(){
	// t=1;
	cin>>n>>k;
	for(int i=1;i<=n+k;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int f=0;f<=k;f++){
		for(int s=0;s<=k-f;s++){
			int lft=k-s-f;
			v.clear();
			int l=f+1;
			int r=n+k-s;
			int sum=a[l]+a[r];
			while(l<r) {
				if(a[l]+a[r]==sum) v.push_back(a[l]),v.push_back(a[r]),l++,r--;
				else if(a[l]+a[r]>sum) r--,lft--;
				else l++,lft--;
				if(!lft) break;
			}
			if(v.size()>=n) {
				for(int i=0;i<n;i++){
					ans.push_back(v[i]);
				}
				sort(ans.begin(),ans.end());
				for(int i=0;i<n;i++){
					cout<<ans[i]<<" ";
				}
				return 0;
			}
		}
	}
	cout<<-1;
}

Compilation message

tabletennis.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main(){
      |       ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:31: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]
   31 |    if(v.size()>=n) {
      |       ~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 896 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 66 ms 2540 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 492 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -