제출 #685671

#제출 시각아이디문제언어결과실행 시간메모리
685671heeheeheehaawTable Tennis (info1cup20_tabletennis)C++17
0 / 100
96 ms7996 KiB
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; int n, k; int v[200005]; void afisare(vector<int> rez) { sort(rez.begin(), rez.end()); for(int i = 0; i < rez.size(); i++) cout<<v[rez[i]]<<" "; cout<<'\n'; return; } vector<int> possible(int sum) { vector<int> rez; int dr = n + k; for(int i = 1; i <= n; i++) { while(v[i] + v[dr] > sum) dr--; if(i >= dr) break; if(v[i] + v[dr] < sum) { rez.clear(); return rez; } rez.push_back(i); rez.push_back(dr); dr--; } if((int)rez.size() == n) return rez; rez.clear(); return rez; } void solve1() { for(int i = 1; i <= n + k; i++) for(int j = i + 1; j <= n + k; j++) { vector<int> rez = possible(v[i] + v[j]); if(rez.size() != 0) { afisare(rez); return; } } cout<<-1<<'\n'; return; } void solve2() { map<int, int> mp; for(int i = 1; i <= k; i++) for(int j = n; j <= n + k; j++) mp[v[i] + v[j]]++; for(auto it: mp) { if(it.second >= k) { vector<int> rez = possible(it.first); if(rez.size() != 0) { afisare(rez); return; } } } return; } int main() { cin>>n>>k; for(int i = 1; i <= n + k; i++) cin>>v[i]; if(n + k <= 4 * k) solve1(); else solve2(); return 0; }

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

tabletennis.cpp: In function 'void afisare(std::vector<int>)':
tabletennis.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < rez.size(); i++)
      |                    ~~^~~~~~~~~~~~
#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...