제출 #746688

#제출 시각아이디문제언어결과실행 시간메모리
746688Abrar_Al_SamitTable Tennis (info1cup20_tabletennis)C++17
100 / 100
333 ms33824 KiB
#include<bits/stdc++.h> using namespace std; const int nax = 150402; int a[nax]; int n, k; void check(int sum) { int l = 1, r = n+k; vector<int>b; int cur = a[1] + a[n+k]; while(l<r) { if(cur>sum) { cur -= a[r]; --r; cur += a[r]; } else if(cur<sum) { cur -= a[l]; ++l; cur += a[l]; } else { b.push_back(a[l]); b.push_back(a[r]); if(b.size()==n) { sort(b.begin(), b.end()); for(int x : b) { cout<<x<<' '; } cout<<'\n'; exit(0); } ++l, --r; cur = a[l] + a[r]; } } } void PlayGround() { cin>>n>>k; for(int i=1; i<=n+k; ++i) { cin>>a[i]; } if(n+k < 4 * k) { for(int i=1; i<=n+k; ++i) { for(int j=i+1; j<=n+k; ++j) { check(a[i]+a[j]); } } } else { map<int, int>cnt; for(int i=1; i<=2*k; ++i) { for(int j=n-k+1; j<=n+k; ++j) { cnt[a[i]+a[j]]++; } } for(auto [x, y] : cnt) { if(y >= k) { check(x); } } } // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); PlayGround(); return 0; }

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

tabletennis.cpp: In function 'void check(int)':
tabletennis.cpp:27:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |    if(b.size()==n) {
      |       ~~~~~~~~^~~
#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...