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>
using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;
const int MAXN = 1510;
int pL[MAXN], pR[MAXN];
int qtd[MAXN], ord[MAXN];
bool cmp(int i, int j) { return qtd[i] > qtd[j]; }
long long find_maximum(int k, vector< vector<int> > x)
{
int n = x.size();
int m = x[0].size();
vector< vector<int> > answer;
for(int i = 0; i < n; i++)
answer.push_back( vector<int>( m , -1 ) );
lli ans = 0;
vector< pair<lli,int> > sum;
for(int i = 0 ; i < n ; i++)
{
qtd[i] = k;
for(int j = 0 ; j < k ; j++)
{
ans -= x[i][j];
sum.push_back( { x[i][j] + x[i][m - k + j] , i } );
}
}
sort( sum.begin() , sum.end() );
reverse( sum.begin() , sum.end() );
for(int i = 0 ; i < (n/2)*k ; i++)
{
ans += sum[i].first;
qtd[ sum[i].second ]--;
}
iota( ord , ord + n , 0 );
for(int i = 0 ; i < n ; i++)
pL[i] = 0, pR[i] = m - 1;
for(int t = 0 ; t < k ; t++)
{
sort( ord , ord + n , cmp );
for(int i = 0 ; i < n/2 ; i++)
answer[ ord[i] ][ pL[ ord[i] ]++ ] = t, qtd[ ord[i] ]--;
for(int i = n/2 ; i < n ; i++)
answer[ ord[i] ][ pR[ ord[i] ]-- ] = t;
}
allocate_tickets( answer );
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... |