# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315601 | VEGAnn | Carnival Tickets (IOI20_tickets) | C++14 | 894 ms | 60540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "tickets.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define i2 array<int,2>
using namespace std;
typedef long long ll;
const int N = 1600;
const ll OO = 1e18;
priority_queue<i2> pq;
int ptr[N];
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
fill(all(row), -1);
answer.push_back(row);
}
ll ans = 0;
for (int i = 0; i < n; i++){
for (int j = 0; j < k; j++)
ans += x[i][m - k + j];
ptr[i] = 0;
pq.push({-x[i][m - k] - x[i][0], i});
}
// add again to pq only if ptr < m
for (int itr = (n / 2) * k; itr > 0; itr--){
i2 now = pq.top(); pq.pop();
ans += now[0];
int id = now[1];
ptr[id]++;
if (ptr[id] < k){
pq.push({-x[id][m - k + ptr[id]] - x[id][ptr[id]], id});
}
}
// add last tickets
for (int i = 0, g1 = 0; i < n; i++){
int now = 0;
for (int j = 0; j < ptr[i]; j++){
answer[i][j] = g1;
g1++;
if (g1 == k) g1 = 0;
}
for (int j = ptr[i], now = g1; j < k; j++){
answer[i][m - k + j] = now;
now++;
if (now == k) now = 0;
}
}
allocate_tickets(answer);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |