Submission #227829

# Submission time Handle Problem Language Result Execution time Memory
227829 2020-04-29T01:23:46 Z blacktulip Table Tennis (info1cup20_tabletennis) C++17
87 / 100
3000 ms 5172 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,sum;
int cev;
string s;
//~ map<int,int> mpp;
vector<int> v;
 
main(void){
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n+k;i++)scanf("%lld",&a[i]);
	for(int i=k+1;i>=1;i--){
		for(int j=n+k;j>=n+k-k+(i-1);j--){
			int bas=i;
			int son=j;
			flag=0;
			cev=0;
			v.clear();
			//~ printf("%d\n",v.size());
			while(bas<son){
				
				if(a[bas]+a[son]==a[i]+a[j]){v.pb(a[bas]);v.pb(a[son]);bas++;son--;cev++;}
				else if(a[bas]+a[son]<a[i]+a[j]){bas++;}
				else if(a[bas]+a[son]>a[i]+a[j]){son--;}
				if(cev>=n/2){flag=1;break;}
			}
			if(flag==1){
				sort(v.begin(),v.end());
				for(int i=0;i<(int)v.size();i++){
					printf("%lld ",v[i]);
				}
				return 0;
			}
		}
	}
	return 0;
}

Compilation message

tabletennis.cpp:35:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~
tabletennis.cpp:37:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n+k;i++)scanf("%lld",&a[i]);
                         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1020 KB Output is correct
2 Correct 50 ms 4968 KB Output is correct
3 Correct 51 ms 4964 KB Output is correct
4 Correct 54 ms 5172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 4328 KB Output is correct
2 Correct 55 ms 4960 KB Output is correct
3 Correct 51 ms 5096 KB Output is correct
4 Correct 51 ms 4968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 66 ms 4328 KB Output is correct
3 Correct 133 ms 4968 KB Output is correct
4 Correct 78 ms 4968 KB Output is correct
5 Correct 127 ms 5092 KB Output is correct
6 Correct 52 ms 5100 KB Output is correct
7 Correct 84 ms 5096 KB Output is correct
8 Correct 122 ms 5092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 364 KB Output is correct
2 Correct 62 ms 4328 KB Output is correct
3 Execution timed out 3087 ms 2944 KB Time limit exceeded
4 Halted 0 ms 0 KB -