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 <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "tickets.h"
#include <vector>
int cur[1501];
int vis[1501];
long long find_maximum(int k,vector<vector<int>> xx) {
int n = xx.size();
int m = xx[0].size();
vector<vector<int>> answer;
llo su=0;
priority_queue<pair<int,pair<int,int>>> ss;
for(int i=0;i<n;i++){
for(int j=m-1;j>=m-k;j--){
su+=xx[i][j];
}
ss.push({-xx[i][m-k]-xx[i][0],{i,0}});
}
//cout<<su<<endl;
for(int j=0;j<(n*k)/2;j++){
pair<int,pair<int,int>> yy=ss.top();
// cout<<yy.a<<","<<yy.b.a<<","<<yy.b.b<<endl;
ss.pop();
su+=yy.a;
cur[yy.b.a]+=1;
if(yy.b.b<k-1){
ss.push({-xx[yy.b.a][m-(k-yy.b.b)+1]-xx[yy.b.a][yy.b.b+1],{yy.b.a,yy.b.b+1}});
}
}
vector<vector<int>> ans;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
row[j] = -1;
}
ans.push_back(row);
}
llo cur2=0;
for(int i=0;i<n;i++){
for(int j=0;j<cur[i];j++){
ans[i][j]=cur2;
cur2=(cur2+1)%k;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
vis[j]=0;
}
for(int j=0;j<m;j++){
if(ans[i][j]>-1){
vis[ans[i][j]]=1;
}
}
vector<int> tt;
for(int j=0;j<k;j++){
if(vis[j]==0){
tt.pb(j);
}
}
for(int j=m-1;j>=m-(k-cur[i]);j--){
ans[i][j]=tt[(m-1)-j];
}
}
allocate_tickets(ans);
return su;
}
# | 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... |