제출 #769531

#제출 시각아이디문제언어결과실행 시간메모리
769531borisAngelovTable Tennis (info1cup20_tabletennis)C++17
100 / 100
95 ms4564 KiB
#include <algorithm> #include <iostream> #include <vector> using namespace std; const int maxn = 200005; int n, k; int a[maxn]; vector<int> solution; bool check(int i, int j) { solution.clear(); int lp = i; int rp = j; int sum = a[lp] + a[rp]; solution.push_back(a[lp]); solution.push_back(a[rp]); ++lp; --rp; while (rp - lp >= 1 && solution.size() <= n - 1) { if (rp - lp + 1 + solution.size() <= n - 1) { return false; } if (a[lp] + a[rp] == sum) { solution.push_back(a[lp]); solution.push_back(a[rp]); ++lp; --rp; continue; } if (a[lp] + a[rp] < sum) { ++lp; continue; } if (a[lp] + a[rp] > sum) { --rp; continue; } } return solution.size() == n; } void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { cin >> n >> k; for (int i = 1; i <= n + k; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { for (int j = n + k; j >= n + i - 1; --j) { if (check(i, j) == true) { sort(solution.begin(), solution.end()); for (auto idx : solution) { cout << idx << ' '; } cout << endl; return 0; } } } return 0; }

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

tabletennis.cpp: In function 'bool check(int, int)':
tabletennis.cpp:30:44: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     while (rp - lp >= 1 && solution.size() <= n - 1)
      |                            ~~~~~~~~~~~~~~~~^~~~~~~~
tabletennis.cpp:32:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         if (rp - lp + 1 + solution.size() <= n - 1)
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
tabletennis.cpp:61:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |     return solution.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...