# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320015 | wildturtle | Stations (IOI20_stations) | C++14 | 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.
#include "tickets.h"
#include<bits/stdc++.h>
using namespace std;
int idx,ans,l,l1,A[500005];
set < pair < int , int > > st;
long long find_maximum(int k, vector< vector < int > > x) {
int n=x.size();
int m=x[0].size();
for(int i=0;i<n;i++) {
for(int j=m-k;j<m;j++) {
ans+=x[i][j];
}
st.insert({x[i][m-k]+x[i][0],i});
}
for(int i=1;i<=(n*k)/2;i++) {
idx=(*st.begin()).second;
ans-=(*st.begin()).first;
st.erase(*st.begin());
A[idx]++;
if(A[idx]<k) st.insert({x[idx][m-k+A[idx]]+x[idx][A[idx]],idx});
}
vector < vector < int > > answer;
for (int i = 0; i < n; i++) {
vector<int> row;
for (int j = 0; j < A[i]; j++) {
row.push_back(l);
l++;
l%=k;
}
for(int j=A[i];j<m-(k-A[i]);j++) {
row.push_back(-1);
}
l1=l;
for(int j=m-(k-A[i]);j<m;j++) {
row.push_back(l1);
l1++;
l1%=k;
}
answer.push_back(row);
}
allocate_tickets(answer);
return ans;
}