제출 #751088

#제출 시각아이디문제언어결과실행 시간메모리
751088StickfishTable Tennis (info1cup20_tabletennis)C++17
72 / 100
91 ms4736 KiB
#include <iostream> #include <algorithm> #include <map> #include <cassert> #include <vector> using namespace std; const int MAXN = 157000; int a[MAXN]; void solve_slow(int n, int k) { map<int, int> mp; for (int i = 0; i < n + k; ++i) { int ctr = n + k - i - 1; for (int t = -k; t <= k; ++t) { if (ctr + t <= i || ctr + t >= n + k) continue; int val = a[i] + a[ctr + t]; ++mp[val]; } } int mxval = 0; int mxcnt = 0; for (auto [val, cnt] : mp) { if (mxcnt < cnt) { mxval = val; mxcnt = cnt; } } assert(mxcnt >= n / 2); vector<int> ans; for (int i = 0; i < n + k; ++i) { int ctr = n + k - i - 1; for (int t = -k; t <= k; ++t) { if (ctr + t <= i || ctr + t >= n + k) continue; int val = a[i] + a[ctr + t]; if (val == mxval) { ans.push_back(a[i]); ans.push_back(a[ctr + t]); } } } while (ans.size() > n) ans.pop_back(); sort(ans.begin(), ans.end()); for (int i = 0; i < n; ++i) { cout << ans[i] << ' '; } cout << '\n'; } signed main() { int n, k; cin >> n >> k; for (int i = 0; i < n + k; ++i) { cin >> a[i]; } if (n * k <= 300000) { solve_slow(n, k); return 0; } }

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

tabletennis.cpp: In function 'void solve_slow(int, int)':
tabletennis.cpp:44:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |     while (ans.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...