# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007468 | u_suck_o | Carnival Tickets (IOI20_tickets) | C++17 | 1 ms | 860 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 SZ 1505
using namespace std;
bool large[SZ][SZ], small[SZ][SZ];
bool used[SZ];
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer = vector<vector<int>>(n, vector<int>(m, -1));
vector<pair<int, pair<int, int>>> v; //{number, {ticket color, ticket id}}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
v.push_back({x[i][j], {i, j}});
}
}
sort(v.begin(), v.end());
long long ans = 0;
int count = 0;
for (int i = v.size()-1; i >= 0; i--) {
if (count == n/2) break;
if (!used[v[i].second.first]) {
ans += v[i].first;
answer[v[i].second.first][v[i].second.second] = 0;
used[v[i].second.first] = true;
count++;
}
}
count = 0;
for (int i = 0; i < v.size(); i++) {
if (count == n/2) break;
if (!used[v[i].second.first]) {
ans -= v[i].first;
answer[v[i].second.first][v[i].second.second] = 0;
used[v[i].second.first] = true;
count++;
}
}
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... |