제출 #826094

#제출 시각아이디문제언어결과실행 시간메모리
826094amunduzbaev카니발 티켓 (IOI20_tickets)C++17
0 / 100
1 ms296 KiB
#include "tickets.h" #include "bits/stdc++.h" using namespace std; #define ar array typedef long long ll; //~ #define int ll ll find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); ll ans = -1; vector<int> lor_; auto check = [&](int mid){ ll res = 0; ar<int, 2> all {}; vector<ar<int, 2>> diff; vector<int> lor(n); for(int i=0;i<n;i++){ if(x[i][m - 1] < mid || mid < x[i][0]){ if(mid < x[i][0]) all[1]++, res += x[i][m - 1] - mid, lor[i] = 1; else all[0]++, res += mid - x[i][0]; continue; } all[0]++; res += mid - x[i][0]; diff.push_back({(x[i][m - 1] - mid) - (mid - x[i][0]), i}); } if(all[1] * 2 > n) return; sort(diff.begin(), diff.end()); while(all[1] * 2 < n){ all[0]--; all[1]++; res += diff.back()[0]; lor[diff.back()[1]] = 1; } if(ans < res){ ans = res; lor_ = lor; } }; for(int i=0;i<n;i++){ check(x[i][0]); check(x[i][1]); } vector<vector<int>> res(n, vector<int>(m, -1)); for(int i=0;i<n;i++){ if(lor_[i]) res[i][m - 1] = 0; else res[i][0] = 0; } allocate_tickets(res); return ans; }
#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...