Submission #692481

# Submission time Handle Problem Language Result Execution time Memory
692481 2023-02-01T14:01:20 Z Ahmed_Solyman Table Tennis (info1cup20_tabletennis) C++14
11 / 100
3000 ms 160544 KB
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    fast
    int n,k;cin>>n>>k;
    vector<int>arr(n+k);
    map<int,bool>vis;
    for(auto &i:arr){
    	cin>>i;
    	vis[i]=1;
    }
    for(int i=0;i<=k;i++){
    	for(int j=n-1;j<n+k;j++){
    		if(i==j)continue;
    		int s=arr[i]+arr[j];
    		int cnt=0;
    		vector<int>v;
    		for(int g=n+k-1;g>=(n+k)/2;g--){
    			cnt+=vis[s-arr[g]]*2;
    			if(vis[s-arr[g]]){
    				v.pb(s-arr[g]);
    				v.pb(arr[g]);
    			}
    		}
    		if(cnt>=n){
    			while(v.sz>n)v.pop_back();
    			sort(all(v));
    			for(auto g:v)cout<<g<<" ";
    			return 0;
    		}
    	}
    }
    return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:61:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |        while(v.sz>n)v.pop_back();
      |              ~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1680 KB Output not subsequence of input
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 140 ms 22088 KB Output is correct
2 Incorrect 208 ms 37436 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 385 ms 26932 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 468 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3063 ms 160544 KB Time limit exceeded
2 Halted 0 ms 0 KB -