Submission #1066342

#TimeUsernameProblemLanguageResultExecution timeMemory
1066342goduadzesabaTable Tennis (info1cup20_tabletennis)C++17
100 / 100
170 ms8904 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=2e5+5,mod=1e9+7; int n,k,a[N],x,y,sm,ans; vector <int> v; map <int,bool> mp; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(0)); cin>>n>>k; for (int i=1; i<=n+k; i++) cin>>a[i]; sort(a+1,a+n+k+1); while (1){ x=rand()%(k+1)+1; y=rand()%(k+1)+n; sm=a[x]+a[y]; if (mp[sm]) continue; mp[sm]=1; v.clear(); x=1; y=n+k; ans=0; while (x<y && v.size()<n && v.size()+y-x+1>=n){ if (a[x]+a[y]<sm){ x++; } else if (a[x]+a[y]>sm){ y--; } else{ v.push_back(a[x]); v.push_back(a[y]); ans++; x++; y--; } } if (ans>=n/2){ sort(v.begin(),v.end()); for (int i:v) cout<<i<<" "; return 0; } } }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:24:25: 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]
   24 |   while (x<y && v.size()<n && v.size()+y-x+1>=n){
      |                 ~~~~~~~~^~
tabletennis.cpp:24:45: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   24 |   while (x<y && v.size()<n && v.size()+y-x+1>=n){
      |                               ~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...