| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 328808 | blue | 카니발 티켓 (IOI20_tickets) | C++17 | 0 ms | 0 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.
vector< vector<int> >* Z;
struct ind
{
int i;
};
bool operator < (ind A, ind B)
{
return (*Z)[A.i].back() - (*Z)[A.i].front() < (*Z)[B.i].back() - (*Z)[B.i].front();
}
long long find_maximum(int k, vector< vector<int> > x)
{
int n = x.size();
int m = x[0].size();
Z = &x;
ind I[n];
for(int i = 0; i < n; i++) I[i] = ind{i};
sort(I, I+n);
vector< vector<int> > s(n);
long long res;
for(int i = 0; i < n/2; i++)
{
s[i] = vector<int>(-1, m);
s[i][0] = 0;
res -= x[i][0];
}
for(int i = n/2; i < n; i++)
{
s[i] = vector<int>(-1, m);
s[i][m-1] = 0;
res += x[i][m-1];
}
allocate_tickets(s);
return res;
}
