제출 #1105190

#제출 시각아이디문제언어결과실행 시간메모리
1105190_callmelucianTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3073 ms4804 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef pair<int,int> pii; typedef tuple<int,int,int> tt; #define all(a) a.begin(), a.end() #define filter(a) a.erase(unique(all(a)), a.end()) const int mn = 2e5 + 5; int a[mn], n, m, k; int calc (int l, int r) { int sum = a[l] + a[r], cnt = 1; l++, r--; while (l <= r) { while (a[l] + a[r] > sum) r--; if (a[l] + a[r] == sum) cnt++, r--; l++; } return cnt; } void findAns (int sum) { int l = 1, r = m; vector<int> ans; while (ans.size() < n) { while (a[l] + a[r] > sum) r--; if (a[l] + a[r] == sum) { ans.push_back(a[l]); ans.push_back(a[r]); r--; } l++; } sort(all(ans)); for (int u : ans) cout << u << " "; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; m = n + k; for (int i = 1; i <= m; i++) cin >> a[i]; for (int l = 1; l <= k + 1; l++) for (int r = m; m - r + l - 1 <= k; r--) if (calc(l, r) >= n / 2) return findAns(a[l] + a[r]), 0; return 0; }

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

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