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 ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
using namespace std;
const int maxn=1e6+10,LOG=17,mod=998244353;
int block = 226, timer = 0;
const ld EPS = 1e-18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bt(i) (1 << (i))
//#define int ll
const int inf=2e9;
#define y1 yy
#define prev pre
#define pii pair <int, int>
ll mni[maxn], mxi[maxn];
ll mx[maxn], mn[maxn];
bool cmp(pii a, pii b)
{
return a.f > b.f;
}
long long find_maximum(int k, vector <vector <int> > a)
{
vector <vector <int> > use, mark;
int n = a.size();
int m = a[0].size();
use = a;
forn(0, i, n-1) forn(0, j, m-1) use[i][j] = -1;
ll ret = 0;
forn(0, iter, k-1)
{
vector <pii> vec;
forn(0, i, n-1)
{
mx[i] = -inf;
mn[i] = inf;
forn(0, j, m-1)
{
if(use[i][j] != -1) continue;
if(mx[i] < a[i][j])
{
mx[i] = a[i][j];
mxi[i] = j;
}
if(mn[i] > a[i][j])
{
mn[i] = a[i][j];
mni[i] = j;
}
}
vec.pb({mx[i]+mn[i], i});
}
sort(all(vec), cmp);
FOR(0, i, n / 2)
{
use[vec[i].s][mxi[vec[i].s]] = iter;
ret += mx[vec[i].s];
}
FOR(n / 2, i, n)
{
use[vec[i].s][mni[vec[i].s]] = iter;
ret -= mn[vec[i].s];
}
}
allocate_tickets(use);
return ret;
}
# | 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... |