제출 #370331

#제출 시각아이디문제언어결과실행 시간메모리
370331A_DTable Tennis (info1cup20_tabletennis)C++14
100 / 100
402 ms45016 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=1e6+100; int a[N]; vector<int> vec; map<int,int> mp; vector<int> v; int n,m,k; int ok(int v) { int l=1,r=m; while(l<r){ int u=a[l]+a[r]; // cout<<l<<" "<<r<<endl; // cout<<u<<" "<<v<<endl; if(u==v){ vec.push_back(a[l]); vec.push_back(a[r]); l++; r--; } else if(u<v)l++; else r--; } //for(auto x:vec)cout<<x<<" ";cout<<endl; while(vec.size()>n)vec.pop_back(); return vec.size()==n; } main() { cin>>n>>k; m=n+k; for(int i=1;i<=m;i++)scanf("%lld",&a[i]); if(m<=4*k){ for(int i=1;i<=k+1;i++){ for(int j=n;j<=m;j++){ if(ok(a[i]+a[j])){ sort(vec.begin(),vec.end()); for(auto x:vec){ printf("%lld ",x); } return 0; } else{ vec.clear(); } } } } else{ for(int i=1;i<=2*k;i++){ for(int j=n-k;j<=m;j++){ mp[a[i]+a[j]]++; } } for(auto x:mp){ if(x.S>=k){ v.push_back(x.F); } } for(auto x:v){ if(ok(x)){ sort(vec.begin(),vec.end()); for(auto y:vec){ printf("%lld ",y); } return 0; } else{ vec.clear(); } } } }

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

tabletennis.cpp: In function 'long long int ok(long long int)':
tabletennis.cpp:31:21: 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]
   31 |     while(vec.size()>n)vec.pop_back();
      |           ~~~~~~~~~~^~
tabletennis.cpp:32:22: 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]
   32 |     return vec.size()==n;
      |            ~~~~~~~~~~^~~
tabletennis.cpp: At global scope:
tabletennis.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   34 | main()
      |      ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:38:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     for(int i=1;i<=m;i++)scanf("%lld",&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...