제출 #1078633

#제출 시각아이디문제언어결과실행 시간메모리
1078633juicy카니발 티켓 (IOI20_tickets)C++17
100 / 100
620 ms92840 KiB
#include "tickets.h" #include <bits/stdc++.h> using namespace std; long long find_maximum(int k, vector<vector<int>> x) { int n = x.size(), m = x[0].size(); long long res = 0; vector<array<int, 3>> cands; for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { cands.push_back({x[i][j] + x[i][m - k + j], i, -j}); res -= x[i][j]; } } sort(cands.rbegin(), cands.rend()); vector<int> cnt(n), ptr(n); for (int i = 0; i < n * k / 2; ++i) { auto [v, r, c] = cands[i]; ++cnt[r]; res += v; } vector a(n, vector<int>(m, -1)); vector<int> ord(n); iota(ord.begin(), ord.end(), 0); for (int t = 0; t < k; ++t) { sort(ord.begin(), ord.end(), [&](int u, int v) { return cnt[u] > cnt[v]; }); for (int i = 0; i < n / 2; ++i) { int u = ord[i]; a[u][m - cnt[u]--] = t; } for (int i = n / 2; i < n; ++i) { int u = ord[i]; a[u][ptr[u]++] = t; } } allocate_tickets(a); return res; }
#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...