제출 #366258

#제출 시각아이디문제언어결과실행 시간메모리
366258Ahmad_HasanTable Tennis (info1cup20_tabletennis)C++17
0 / 100
83 ms11360 KiB
#include <bits/stdc++.h> #define int long long /** |||||||||| ||||| ||||| |||||||||| ||||||||||||| ||||| ||||| ||||| |||| |||||| ||||| ||||| ||||| ||||||||||||||||| ||||||||||||||| |||||||||| ||||||||||||||||||| ||||||||||||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| ||||| |||||||||| AHMED;HASSAN;SAEED; */ using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k; cin>>n>>k; vector<int>v(n+k); map<int,int >mp,mp2; int nn=n+k; for(int i=0;i<nn;i++){ cin>>v[i]; } vector<vector<pair<int,int> > >pos((k+10)*(k+10)); vector<int>sums; int cr=0; for(int i=0;i<nn&&i<k+5;i++){ if(nn-1-i>i) sums.push_back(v[i]+v[nn-1-i]); } int mxi=0; int f=0; for(int j=0;j<sums.size();j++){ for(int i=0;i<nn;i++){ vector<int>::iterator it2=lower_bound(v.begin(),v.end(),sums[j]-v[i]); if(it2==v.end()||*it2!=sums[j]-v[i])continue; int vl=it2-v.begin(); if(vl>i){ pos[j].push_back({i,vl}); if(pos[j].size()>=n/2){ f=1; break; } } } } /** for(int i=0;i<pos.size();i++){ for(int j=0;j<pos[i].size();j++){ cout<<pos[i][j].first<<'-'<<pos[i][j].second<<' '; } cout<<'\n'; } */ for(int i=0;i<pos.size();i++) if(pos[i].size()>pos[mxi].size()) mxi=i; vector<int>ans(n); int l=0,r=n-1; for(int i=0;i<pos[mxi].size()&&i<n/2;i++){ ans[l]=(v[pos[mxi][i].first]); ans[r]=(v[pos[mxi][i].second]); l++; r--; } for(int i=0;i<ans.size();i++) cout<<ans[i]<<' '; return 0; } /** 4 3 100000000000 200000000000 300000000000 400000000000 800000000000 1000000000000 2000000000000 */

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

tabletennis.cpp: In function 'int32_t main()':
tabletennis.cpp:39:18: 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]
   39 |     for(int j=0;j<sums.size();j++){
      |                 ~^~~~~~~~~~~~
tabletennis.cpp:46:33: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |                 if(pos[j].size()>=n/2){
      |                    ~~~~~~~~~~~~~^~~~~
tabletennis.cpp:62:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0;i<pos.size();i++)
      |                 ~^~~~~~~~~~~
tabletennis.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i=0;i<pos[mxi].size()&&i<n/2;i++){
      |                 ~^~~~~~~~~~~~~~~~
tabletennis.cpp:72:18: 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]
   72 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
tabletennis.cpp:32:9: warning: unused variable 'cr' [-Wunused-variable]
   32 |     int cr=0;
      |         ^~
tabletennis.cpp:38:9: warning: variable 'f' set but not used [-Wunused-but-set-variable]
   38 |     int f=0;
      |         ^
#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...