Submission #373238

#TimeUsernameProblemLanguageResultExecution timeMemory
373238ahmedfouadnewTable Tennis (info1cup20_tabletennis)C++17
49 / 100
565 ms12340 KiB
#include<bits/stdc++.h> using namespace std; #define s second #define f first #define pb push_back //#define int long long //#define double long double int n,k; int a[200005]; unordered_map<int,int>mp; int mx,mxi; void fun(int ii,int s,int e) { e=min(e,n+k-1); s=max(0,s); for(int i=s;i<=e;i++) { if(i==ii) continue; mp[a[ii]+a[i]]++; if(mp[a[ii]+a[i]]>mx) { mx=mp[a[ii]+a[i]]; mxi=a[ii]+a[i]; } } } signed main() { scanf("%d%d",&n,&k); for(int i=0;i<n+k;i++) { scanf("%d",a+i); } sort(a,a+n+k); for(int i=0;i<(n+k)/2+k;i++) { fun(i,(n+k-1-i)-k-1,(n+k-1-i)+k+1); } vector<int>ans; int cnt=n; int e=n+k-1; for(int i=0;i<n+k;i++) { int cur=e; bool ok=0; while(e-cur<=k) { if(a[i]+a[cur]==mxi) { ok=1; ans.pb(a[i]); ans.pb(a[cur]); break; } cur--; } if(ok) { cnt-=2; e=cur-1; } if(cnt==0) break; } sort(ans.begin(),ans.end()); for(int i=0;i<ans.size();i++) { if(i) printf(" "); printf("%d",ans[i]); } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for(int i=0;i<ans.size();i++)
      |               ~^~~~~~~~~~~
tabletennis.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |   scanf("%d%d",&n,&k);
      |   ~~~~~^~~~~~~~~~~~~~
tabletennis.cpp:32:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |       scanf("%d",a+i);
      |       ~~~~~^~~~~~~~~~
#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...