제출 #791084

#제출 시각아이디문제언어결과실행 시간메모리
791084AndreyTable Tennis (info1cup20_tabletennis)C++14
100 / 100
176 ms4568 KiB
#include <bits/stdc++.h> using namespace std; int n,k; vector<int> ans(0); vector<int> haha(0); bool check(int a) { ans.clear(); int l = 0,r = n+k-1; while(l < r) { if(r-l+1+ans.size() < n) { return false; } while(r > l && haha[l]+haha[r] > a) { r--; } if(r <= l) { return false; } if(haha[r]+haha[l] == a) { ans.push_back(haha[l]); ans.push_back(haha[r]); if(ans.size() == n) { return true; } } l++; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; int a; for(int i = 0; i < n+k; i++) { cin >> a; haha.push_back(a); } for(int i = 0; i < k+1; i++) { for(int j = n+k-1; j >= n-1 && j > i; j--) { if(check(haha[i]+haha[j])) { sort(ans.begin(),ans.end()); for(int y = 0; y < n; y++) { cout << ans[y] << " "; } cout << endl; return 0; } } } return 0; }

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

tabletennis.cpp: In function 'bool check(int)':
tabletennis.cpp:12:29: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |         if(r-l+1+ans.size() < n) {
      |            ~~~~~~~~~~~~~~~~~^~~
tabletennis.cpp:24:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |             if(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...