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 rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--)
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
const int inf = 1001001001;
const ll linf = 1001001001001001001;
template<class T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll find_maximum(int k, vvi x) {
int n = x.size();
int m = x[0].size();
ll ans = 0;
// 0 -> minus, 1 -> plus
vvi alloc(n, vi(m, -1));
vi cnt(n);
vp ls;
rep(i, n) {
rep(j, k) {
ans -= x[i][j];
ls.eb(x[i][j] + x[i][m - k + j], i);
}
}
sort(rall(ls));
rep(i, n * k / 2) {
ans += ls[i].first;
cnt[ls[i].second]++;
}
rep(i, n) {
rep(j, k - cnt[i]) alloc[i][j] = 0;
rep(j, cnt[i]) alloc[i][m - 1 - j] = 1;
}
// rep(i,n) rep(j,m) cerr << alloc[i][j] << (j == m-1 ? '\n' : ' ');
// cerr << endl;
auto proc = [&](int &i) {
int pi = i;
i = (i < k - 1 ? i + 1 : 0);
return pi;
};
int now = 0;
rep(i, n) {
int it = now;
rep(j, m) {
if (alloc[i][j] == -1) continue;
if (alloc[i][j] == 0) proc(now);
alloc[i][j] = proc(it);
}
}
assert(now == 0);
allocate_tickets(alloc);
return ans;
}
# | 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... |