제출 #377644

#제출 시각아이디문제언어결과실행 시간메모리
377644wildturtleTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3063 ms52828 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,i,e,f,g,n,m,k,l,cnt,A[500005]; map <long long,long long> mp,mp1,mp2; vector <long long> v,st; long long check(long long sum) { for(long long i=1;i<=n;i++) mp1[A[i]]++; cnt=0; v.clear(); for(long long i=1;i<=n;i++) { if(mp1[A[i]]==0) continue; mp1[A[i]]--; if(mp1[sum-A[i]]>=1) { cnt++; mp1[sum-A[i]]=0; v.push_back(A[i]); v.push_back(sum-A[i]); if(cnt==(n-k)/2) break; } } mp1.clear(); if(cnt>=(n-k)/2) return 1; else return 0; } int main() { ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>k; n+=k; for(long long i=1;i<=n;i++) { cin>>A[i]; } sort(A+1,A+1+n); if(n>=4*k) { for(long long i=1;i<=2*k;i++) { for(long long j=n-2*k+1;j<=n;j++) { mp[A[i]+A[j]]++; } } for(long long i=1;i<=2*k;i++) { for(long long j=n-2*k+1;j<=n;j++) { if(mp[A[i]+A[j]]>=k) { if(mp2[A[i]+A[j]]==0) st.push_back(A[i]+A[j]); mp2[A[i]+A[j]]=1; } } } for(long long i=0;i<st.size();i++) { if(check(st[i])) break; } sort(v.begin(),v.end()); for(long long i=0;i<v.size();i++) cout<<v[i]<<" "; } else { for(long long i=1;i<=k;i++) { for(long long j=n-k+i-1;j<=n;j++) { if(mp2[A[i]+A[j]]==0) st.push_back(A[i]+A[j]); mp2[A[i]+A[j]]=1; } } for(long long i=0;i<st.size();i++) { if(check(st[i])) break; } sort(v.begin(),v.end()); for(long long i=0;i<v.size();i++) cout<<v[i]<<" "; } }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:45:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(long long i=0;i<st.size();i++) {
      |                           ~^~~~~~~~~~
tabletennis.cpp:49:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(long long i=0;i<v.size();i++)
      |                           ~^~~~~~~~~
tabletennis.cpp:59:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for(long long i=0;i<st.size();i++) {
      |                           ~^~~~~~~~~~
tabletennis.cpp:63:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(long long i=0;i<v.size();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...