제출 #762351

#제출 시각아이디문제언어결과실행 시간메모리
762351voliaanykTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3069 ms6552 KiB
#include "bits/stdc++.h" using namespace std; #define DIM 160007 #define DIM2 2007 #define fi first #define se second #define mod 1000000007 typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; ll n, k, a[DIM]; vector<ll> res; set<ll> s; bool check(ll d){ ll l = 1, r = n+k; res.clear(); while(l<r){ if(a[r]+a[l] == d){ res.push_back(a[l]); res.push_back(a[r]); r--; l++; } else if(a[r] + a[l] > d) r--; else l++; if(res.size()>=n) return true; } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; for(int i=1;i<=n+k;i++){ cin>>a[i]; } for(int i=1;i<=k+1;i++){ for(int j=n+k;j>=n+i-1;j--){ if(i<j) s.insert(a[j]+a[i]); } } for(auto r:s){ if(check(r)){ sort(res.begin(), res.end()); for(int i=0;i<res.size();i++){ cout<<res[i]<<" "; } cout<<endl; return 0; } } return 0; } /* 4 3 1 2 3 4 8 10 20 4 2 1 2 3 4 5 6 */

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

tabletennis.cpp: In function 'bool check(ll)':
tabletennis.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   35 |         if(res.size()>=n) return true;
      |            ~~~~~~~~~~^~~
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:64:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             for(int i=0;i<res.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...