제출 #690757

#제출 시각아이디문제언어결과실행 시간메모리
690757andrei_iorgulescuTable Tennis (info1cup20_tabletennis)C++14
100 / 100
91 ms4608 KiB
#include <bits/stdc++.h> using namespace std; int n,k,a[150500]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for (int i = 1; i <= n + k; i++) cin >> a[i]; sort(a + 1,a + n + k + 1); for (int i = 1; i <= k + 1; i++) { for (int j = n + k; j >= n - 1; j--) { int sum = a[i] + a[j]; int st = i + 1,dr = j - 1; vector<int>sol; sol.push_back(a[i]); sol.push_back(a[j]); while (st < dr and sol.size() < n and sol.size() + (dr - st + 1) >= n) { if (a[st] + a[dr] == sum) { sol.push_back(a[st]); sol.push_back(a[dr]); st++; dr--; } else if (a[st] + a[dr] > sum) dr--; else st++; } if (sol.size() == n) { sort(sol.begin(),sol.end()); for (int j = 0; j < n; j++) cout << sol[j] << ' '; return 0; } } } return 0; }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:25:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |             while (st < dr and sol.size() < n and sol.size() + (dr - st + 1) >= n)
      |                                ~~~~~~~~~~~^~~
tabletennis.cpp:25:78: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |             while (st < dr and sol.size() < n and sol.size() + (dr - st + 1) >= n)
      |                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
tabletennis.cpp:39:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |             if (sol.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...