제출 #373316

#제출 시각아이디문제언어결과실행 시간메모리
373316ahmedfouadnewTable Tennis (info1cup20_tabletennis)C++17
9 / 100
3061 ms76496 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; unordered_map<int,int>mp2; int mx,mxi; bool okk; void fun(int ii,int s,int e) { if(okk) return; 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]; } if(mp[a[ii]+a[i]]>n*2) { okk=1; break; } } } signed main() { scanf("%d%d",&n,&k); for(int i=0;i<n+k;i++) { scanf("%d",a+i); mp2[a[i]]=1; } sort(a,a+n+k); for(int i=0;i<n+k;i++) { fun(i,(n+k-1-i)-k-1,(n+k-1-i)); } vector<int>ans; int cnt=n; int e=n+k-1; for(int i=0;i<n+k;i++) { if(mp2[mxi-a[i]]) { cnt-=2; ans.pb(a[i]); ans.pb(mxi-a[i]); } 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; }

컴파일 시 표준 에러 (stderr) 메시지

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