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 ll;
const int MX=1505;
int cur[MX];
long long find_maximum(int K, std::vector<std::vector<int>> d) {
int N=d.size();
int M=d[0].size();
ll ans=0;
vector<pair<int,int>> v;
for(int i=0;i<N;i++) {
for(int j=0;j<M;j++) {
if(d[i][j]) break;
cur[i]++;
}
v.push_back({cur[i],i});
}
// for each k, we try to find N/2 nodes with largest cur_i and set it to fill in the negatives, and other N/2 o fill in the positives
vector<int> fr(N), bk(N,M-1);
vector<vector<int>> s(N,vector<int>(M,-1));
for(int x=0;x<K;x++) {
sort(v.rbegin(),v.rend());
for(int j=0;j<N/2;j++) {
auto &[y,i]=v[j];
s[i][fr[i]]=x;
ans-=d[i][fr[i]];
fr[i]++;
y--;
}
for(int j=N/2;j<N;j++) {
auto &[y,i]=v[j];
s[i][bk[i]]=x;
ans+=d[i][bk[i]];
bk[i]--;
}
}
allocate_tickets(s);
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... |