# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623261 | 1bin | Carnival Tickets (IOI20_tickets) | C++14 | 775 ms | 92836 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;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e3 + 5;
ll find_maximum(int k, vector<vector<int>> x){
int n = x.size();
int m = x[0].size();
vector<vector<int>> s(n, vector<int> (m, -1));
vector<pair<ll, int>> v;
vector<int> cnt(n);
ll ans = 0;
for(int i = 0; i < n; i++)
for(int j = k - 1, l = m - 1; j >= 0; j--, l--){
ans -= x[i][j];
v.emplace_back(x[i][j] + x[i][l], i);
}
sort(all(v));
for(int i = n * k / 2; i < n * k; i++){
auto& [t, y] = v[i];
ans += t; cnt[y]++;
}
priority_queue<pair<int, int>> mn;
for(int i = 0; i < n; i++) mn.emplace(k - 1 - cnt[i], i);
for(int i = 0; i < k; i++){
vector<pair<int, int>> tmn;
vector<int> chk(n);
for(int j = 0; j < n / 2; j++){
auto[t, y] = mn.top(); mn.pop();
s[y][t] = i; chk[y] = 1;
tmn.emplace_back(--t, y);
}
for(int j = 0; j < n; j++){
if(chk[j]) continue;
s[j][m - cnt[j]] = i; cnt[j]--;
}
for(auto p : tmn) mn.emplace(p);
}
allocate_tickets(s);
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... |