제출 #424460

#제출 시각아이디문제언어결과실행 시간메모리
424460jamezzzTable Tennis (info1cup20_tabletennis)C++17
100 / 100
375 ms33692 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define all(x) x.begin(),x.end() int n,k,v; vector<int> s,ans; map<int,int> cnt; int main(){ sf("%d%d",&n,&k); n+=k; for(int i=0;i<n;++i){ sf("%d",&v); s.push_back(v); } sort(all(s)); if(n>=4*k){ for(int i=0;i<2*k;++i){ for(int j=n-2*k;j<n;++j){ cnt[s[i]+s[j]]+=1; } } } else{ for(int i=0;i<n;++i){ for(int j=i+1;j<n;++j)cnt[s[i]+s[j]]=k; } } for(auto it:cnt){ if(it.se>=k){ ans.clear(); int cr=n-1; for(int i=0;i<n;++i){ if(s[i]>=it.fi-s[i])break; while(it.fi-s[i]<s[cr])--cr; if(it.fi-s[i]==s[cr]){ ans.pb(s[i]); ans.pb(it.fi-s[i]); --cr; } if(ans.size()==n-k)break; } if(ans.size()==n-k)break; } } sort(all(ans)); for(int x:ans)pf("%d ",x); pf("\n"); }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:47:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     if(ans.size()==n-k)break;
      |        ~~~~~~~~~~^~~~~
tabletennis.cpp:49:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |    if(ans.size()==n-k)break;
      |       ~~~~~~~~~~^~~~~
tabletennis.cpp:16:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  sf("%d%d",&n,&k);
      |    ^
tabletennis.cpp:19:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   sf("%d",&v);
      |     ^
#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...