제출 #818565

#제출 시각아이디문제언어결과실행 시간메모리
818565Soumya1Table Tennis (info1cup20_tabletennis)C++17
100 / 100
263 ms33740 KiB
#include <bits/stdc++.h> #ifdef __LOCAL__ #include <debug_local.h> #endif using namespace std; void testCase() { int n, k; cin >> n >> k; vector<int> a(n + k); for (int &i : a) cin >> i; sort(a.begin(), a.end()); int N = n + k; auto check = [&](int s) { int i = 0, j = N - 1; vector<int> v; while (i < j) { if (a[i] + a[j] == s) { v.push_back(a[i]); v.push_back(a[j]); i++, j--; } else if (a[i] + a[j] > s) { j--; } else { i++; } if (v.size() == n) { sort(v.begin(), v.end()); for (int i : v) cout << i << " "; cout << "\n"; exit(0); } } }; if (4 * k >= n) { for (int i = 0; i < k + 1; i++) { for (int j = N - 1; j >= N - k - 1; j--) { check(a[i] + a[j]); } } } else { map<int, int> cnt; for (int i = 0; i < 2 * k; i++) { for (int j = N - 1; j >= N - 2 * k; j--) { cnt[a[i] + a[j]]++; } } for (auto [x, y] : cnt) { if (y >= k) check(x); } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); testCase(); return 0; }

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

tabletennis.cpp: In lambda function:
tabletennis.cpp:26:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |       if (v.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...