# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1052816 | pcc | Carnival Tickets (IOI20_tickets) | C++17 | 511 ms | 76168 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 <vector>
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
/*
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++) {
if (j < k) {
row[j] = j;
} else {
row[j] = -1;
}
}
answer.push_back(row);
}
allocate_tickets(answer);
return 1;
*/
const ll inf = 1e18;
const int mxn = 2022;
vector<vector<int>> ansv;
int len[mxn];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int N = x.size();
int M = x[0].size();
int K = k;
ll sum = 0;
for(int i = 0;i<N;i++){
for(int j = 0;j<K;j++){
sum -= x[i][j];
}
len[i] = K;
}
priority_queue<pll,vector<pll>,less<pll>> pq;
for(int i = 0;i<N;i++){
pq.push(pll(x[i].end()[-1]+x[i][K-1],i));
}
for(int i = 0;i<N*K/2;i++){
auto [val,pos] = pq.top();
pq.pop();
sum += val;
len[pos]--;
ll p = len[pos];
if(p)pq.push(pll(x[pos].end()[-K+p-1]+x[pos][p-1],pos));
}
ansv = vector<vector<int>>(N,vector<int>(M,-1));
int C = 0;
for(int i = 0;i<N;i++){
for(int j = 0;j<len[i];j++){
ansv[i][j] = C;C = (C+1)%K;
}
}
for(int i = 0;i<N;i++){
set<int> st;
for(int j = 0;j<K;j++)st.insert(j);
for(int j = 0;j<M;j++){
if(ansv[i][j] != -1)st.erase(ansv[i][j]);
}
assert(st.size() == K-len[i]);
for(int j = 0;j<K-len[i];j++){
ansv[i].end()[-1-j] = *st.begin();
st.erase(st.begin());
}
}
allocate_tickets(ansv);
return sum;
}
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... |