제출 #369159

#제출 시각아이디문제언어결과실행 시간메모리
369159dooweyTable Tennis (info1cup20_tabletennis)C++14
100 / 100
952 ms5484 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int main(){ fastIO; //freopen("in.txt","r",stdin); int n, k; cin >> n >> k; int m = (n + k); vector<int> q(m); for(int i = 0; i < m ; i ++) cin >> q[i]; sort(q.begin(), q.end()); vector<pii> tak; for(int i = 0 ; i < m ; i ++ ){ for(int j = 1; j <= k + 1; j ++ ){ if(i + j < m && i + 1 >= n/2 && m-(i+j) >= n/2){ tak.push_back(mp(i,i+j)); } } } random_shuffle(tak.begin(), tak.end()); int pari = 0; int rem = n/2; vector<int> soln; int ci, cj; int pi, pj; bool brok; for(auto pari : tak){ rem = n/2-1; pi = pari.fi; pj = pari.se; soln.clear(); soln.push_back(pi); soln.push_back(pj); ci = pi-1; cj = pj+1; while(rem > 0){ if(ci < 0 || cj >= m || (ci + 1) < rem || (m-cj) < rem) break; if(q[pi]+q[pj] == q[ci]+q[cj]){ soln.push_back(ci); soln.push_back(cj); pi = ci; pj = cj; ci -- ; cj ++ ; rem -- ; } else{ if(q[ci]+q[cj] > q[pi]+q[pj]){ ci--; } else{ cj++; } } } if(rem == 0){ sort(soln.begin(), soln.end()); for(auto x : soln) cout << q[x] << " "; cout << "\n"; return 0; } } return 0; }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:32:9: warning: unused variable 'pari' [-Wunused-variable]
   32 |     int pari = 0;
      |         ^~~~
tabletennis.cpp:37:10: warning: unused variable 'brok' [-Wunused-variable]
   37 |     bool brok;
      |          ^~~~
#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...