제출 #362142

#제출 시각아이디문제언어결과실행 시간메모리
362142Sorting카니발 티켓 (IOI20_tickets)C++17
100 / 100
868 ms85156 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1500 + 3; vector<vector<int>> x, answer; int n, m, k, idx[N]; array<int, 2> arr[N]; void clear(){ } ll solve(){ clear(); ll ans = 0; priority_queue<array<int, 2>> pq; int add = n * k / 2; for(int i = 0; i < n; ++i){ idx[i] = 0; pq.push({-x[i][0] - x[i][m - k], i}); } while(add--){ auto [score, i] = pq.top(); pq.pop(); idx[i]++; if(idx[i] < k) pq.push({-x[i][idx[i]] - x[i][m - k + idx[i]], i}); } for(int i = 0; i < n; ++i){ for(int j = 0; j < idx[i]; ++j){ answer[i][j] = 1; ans -= x[i][j]; } for(int j = idx[i] + m - k; j < m; ++j){ answer[i][j] = 2; ans += x[i][j]; } } int cnt_1 = 0, cnt_2 = 0; for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ if(answer[i][j] == -1) continue; if(answer[i][j] == 1){ answer[i][j] = cnt_1; cnt_1 = (cnt_1 + 1) % k; cnt_2 = cnt_1; } else{ answer[i][j] = cnt_2; cnt_2 = (cnt_2 + 1) % k; } } } return ans; } long long find_maximum(int _k, vector<vector<int>> _x) { k = _k; x = _x; n = x.size(); m = x[0].size(); answer.clear(); answer.resize(n, vector<int>(m, -1)); ll ans = solve(); allocate_tickets(answer); 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...