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;
long long l, x, y, a[500005], sum, n, m;
set<pair<int, int> >s;
vector<vector<int> >answer;
vector<int>vec;
long long find_maximum(int k, vector<vector<int> >v){
n=v.size();
m=v[0].size();
for(int i=0; i<n; i++){
for(int j=m-k; j<m; j++)
sum+=v[i][j];
s.insert({v[i][m-k]+v[i][0], i});
}
for(int i=1; i<=(k*n)/2; i++){
l=(*s.begin()).second;
sum-=(*s.begin()).first;
s.erase(*s.begin());
a[l]++;
if(a[l]<k) s.insert({v[l][m-k+a[l]]+v[l][a[l]], l});
}
for(int i=0; i<n; i++){
vec.clear();
for(int j=0; j<a[i]; j++){
vec.push_back(x);
x=(x+1)%k;
}
for(int j=a[i]; j<m-k+a[i]; j++)
vec.push_back(-1);
y=x;
for(int j=m-k+a[i]; j<m; j++){
vec.push_back(y);
y=(y+1)%k;
}
answer.push_back(vec);
}
allocate_tickets(answer);
return sum;
}
# | 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... |