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<iostream>
#include <vector>
#include<algorithm>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define dforn(i, n) for(int i=n-1; i>=0; --i)
#define dforsn(i, s, n) for(int i=n-1; i>=s; --i)
#define PB push_back
#define F first
#define S second
const int MAXN = 1510;
int n, m;
long long find_maximum(int k, std::vector<std::vector<int>> x) {
n = (int)x.size();
m = (int)x[0].size();
ll ret=0;
vector<vector<int>> ans(n, vector<int>(m, -1));
vector<vector<pii>> wii(n, vector<pii>(m));
forn(i, n){
forn(j, m) wii[i][j] = {x[i][j], j};
sort(wii[i].begin(), wii[i].end());
forn(j, k) ret-=wii[i][j].F;
}
vector<int> hist(n, 0), bh(n, 0);
vector<pii> res;
forn(i, n) forn(j, k) res.PB({wii[i][j].F + wii[i][m-k+j].F, i});
sort(res.begin(), res.end(), greater<pii>());
forn(i, (n/2)*k){
ret+=res[i].F;
hist[res[i].S]++;
}
forn(i, n) bh[i]=hist[i];
dforsn(i, 1, k+1){
int cnt = (n/2);
forn(j, n) cnt-=(hist[j]==i);
forn(j, n){
if(hist[j]==i || (hist[j]>0 && cnt>0)){
if(hist[j]<i) --cnt;
--hist[j];
ans[j][wii[j][hist[j]+m-bh[j]].S] = i-1;
}
else ans[j][wii[j][i - hist[j] - 1].S] = i-1;
}
}
allocate_tickets(ans);
return ret;
}
# | 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... |