| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 639146 | slime | Carnival Tickets (IOI20_tickets) | C++14 | 1052 ms | 114520 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"
using namespace std;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
row[j] = -1;
}
answer.push_back(row);
}
priority_queue<pair<long long, pair<int, int> > > pq;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
pq.push({x[i][j], {i, j}});
}
}
int round[m];
for(int i=0; i<m; i++) round[i] = 0;
long long ans = 0;
for(int i=0; i<n*m/2; i++) {
int ii = pq.top().second.first;
int jj = pq.top().second.second;
ans += pq.top().first;
pq.pop();
answer[ii][jj] = 0;
}
for(int i=0; i<n*m/2; i++) {
ans -= pq.top().first;
pq.pop();
}
int nxt = 0;
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
if(answer[i][j] == 0) {
answer[i][j] = nxt;
nxt = (nxt + 1) % m;
}
}
}
for(int i=0; i<n; i++) {
bool used[m];
for(int j=0; j<m; j++) {
used[j] = 0;
}
for(int j=0; j<m; j++) {
if(answer[i][j] >= 0) used[answer[i][j]] = 1;
}
int rb = 0;
for(int j=0; j<m; j++) {
if(answer[i][j] == -1) {
while(used[rb]) rb++;
answer[i][j] = rb;
used[rb] = 1;
}
}
}
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... | ||||
