제출 #303023

#제출 시각아이디문제언어결과실행 시간메모리
303023tutis카니발 티켓 (IOI20_tickets)C++17
11 / 100
149 ms760 KiB
#include "tickets.h" #include <vector> #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(); int m = x[0].size(); vector<vector<int>> answer(n, vector<int>(m, -1)); int a[n], b[n]; for (int i = 0; i < n; i++) { a[i] = 0; b[i] = m - 1; } long long ret = 0; for (int g = 0; g < k; g++) { vector<bool>av(n, true); int c = n / 2; set<pair<int, int>, greater<pair<int, int>>>A; for (int i = 0; i < n; i++) A.insert({x[i][b[i]], i}); while (c--) { pair<int, pair<int, int>>mx = { -1, {0, 1}}; for (int i = 0; i < n; i++) { if (av[i] == false) continue; A.erase({x[i][b[i]], i}); int j = A.begin()->second; mx = max(mx, {x[j][b[j]] - x[i][a[i]], {i, j}}); A.insert({x[i][b[i]], i}); } ret += mx.first; A.erase({x[mx.second.first][b[mx.second.first]], mx.second.first}); A.erase({x[mx.second.second][b[mx.second.second]], mx.second.second}); answer[mx.second.first][a[mx.second.first]] = g; answer[mx.second.second][b[mx.second.second]] = g; a[mx.second.first]++; b[mx.second.second]--; av[mx.second.first] = false; av[mx.second.second] = false; } } allocate_tickets(answer); return ret; }
#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...