제출 #675181

#제출 시각아이디문제언어결과실행 시간메모리
675181hotboy2703Table Tennis (info1cup20_tabletennis)C++14
100 / 100
532 ms32376 KiB
#include<bits/stdc++.h> using namespace std; int a[151000]; int n,k; bool check(int x){ int l = 1; int r = n; int cnt = 0; while (l < r){ if (a[l] + a[r] > x){cnt++;r--;} else if (a[l] + a[r] < x){l++;cnt++;} else{l++;r--;} if (cnt > k)return 0; } vector <int> ans; l = 1; r = n; while (l < r){ if (a[l] + a[r] > x){r--;} else if (a[l] + a[r] < x){l++;} else{if (ans.size() < n - k){ans.push_back(a[l]);ans.push_back(a[r]);}l++;r--;} } sort(ans.begin(),ans.end()); for (auto y:ans)cout<<y<<' '; cout<<'\n'; return 1; } int main(){ ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr); cin>>n>>k;n += k; for (int i = 1;i <= n;i ++){ cin>>a[i]; } map <int,int> cnt; for (int i = 1;i <= 2 * k && i <= n;i ++){ for (int j = max(1,n - 2 * k + 1);j <= n;j ++){ cnt[a[i] + a[j]]++; } } for (auto x:cnt){ if (check(x.first))return 0; } }

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

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