제출 #535800

#제출 시각아이디문제언어결과실행 시간메모리
535800KoD카니발 티켓 (IOI20_tickets)C++17
100 / 100
601 ms76204 KiB
#include <bits/stdc++.h> #include "tickets.h" using std::vector; using std::array; using std::pair; using std::tuple; using ll = long long; ll find_maximum(int K, vector<vector<int>> X) { const int N = X.size(); const int M = X[0].size(); ll score = 0; vector<int> small(N, K); std::priority_queue<pair<int, int>> heap; for (int i = 0; i < N; ++i) { for (int j = 0; j < K; ++j) { score -= X[i][j]; } heap.emplace(X[i][M - 1] + X[i][K - 1], i); } for (int k = 0; k < N * K / 2; ++k) { const auto [x, i] = heap.top(); heap.pop(); score += x; small[i] -= 1; if (small[i] > 0) { heap.emplace(X[i][M - K + small[i] - 1] + X[i][small[i] - 1], i); } } vector alloc(N, vector(M, -1)); int a = 0, b = K - 1; for (int i = 0; i < N; ++i) { for (int j = 0; j < small[i]; ++j) { alloc[i][j] = a; a = (a + 1) % K; } for (int j = 0; j < K - small[i]; ++j) { alloc[i][M - j - 1] = b; b = (b + K - 1) % K; } } allocate_tickets(alloc); return score; }
#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...