Submission #1066333

#TimeUsernameProblemLanguageResultExecution timeMemory
1066333goduadzesabaTable Tennis (info1cup20_tabletennis)C++17
87 / 100
3069 ms4472 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; 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]; v.clear(); x=1; y=n+k; ans=0; while (x<y){ if (a[x]+a[y]<sm){ x++; } else if (a[x]+a[y]>sm){ y--; } else{ if (v.size()<n){ 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:28:17: 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]
   28 |     if (v.size()<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...