This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "tickets.h"
namespace TEST1 {
ll find_maximum(int k, VVI table) {
int n = table.size();
int m = table[0].size();
VI a;
rep(i, n) a.pb(table[i][0]);
sort(all(a));
ll ans = 0;
rep(i, n/2) ans -= a[i];
rep(i, n/2) ans += a[i + n/2];
VVI answ(n, VI(m, 0));
allocate_tickets(answ);
return ans;
}
};
ll find_maximum(int k, VVI table) {
int n = table.size();
int m = table[0].size();
if (m == 1) return TEST1::find_maximum(k, table);
VI mek, zro;
mek = zro = VI(n, -1);
rep(i, n) rep(j, m) {
if (!table[i][j]) {
zro[i] = j;
}
}
rep(i, n) mek[i] = zro[i]+1;
VVI ans(n, VI(m, -1));
ll answ = 0;
rep(i, k) {
int cnt = 0;
rep(j, n) {
if (cnt >= n/2) {
if (zro[j] >= 0) {
ans[j][zro[j]--] = i;
} else {
ans[j][mek[j]++] = i;
cnt++;
}
} else {
if (mek[j] < m) {
ans[j][mek[j]++] = i;
cnt++;
answ++;
} else {
ans[j][zro[j]--] = i;
}
}
}
}
allocate_tickets(ans);
return answ;
}
# | 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... |