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>
#include "tickets.h"
using namespace std;
int cnt[1505];
long long find_maximum(int k , vector<vector<int>> a){
int n = a.size() , m = a[0].size();
/// nk/2 maximums - nk/2 minimums
priority_queue<pair<int , int>> pq;
long long ans = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < k; ++j) ans += a[i][m - k + j] ,pq.emplace(-a[i][j] - a[i][m - k + j] , i);
}
for(int i = 0; i < n * k / 2; ++i) {auto x = pq.top(); pq.pop(); cnt[x.second]++, ans += x.first;}
vector<vector<int>> r(n , vector<int>(m , -1));
/// nk/2 divide into n/2 groups
int mnL = 0 , mxR = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < cnt[i]; ++j) r[i][j] = mnL++ , mnL%= k;
mxR = mnL;
for(int j = m - k + cnt[i]; j < m; ++j) r[i][j] = mxR++ , mxR%= k;
}
allocate_tickets(r);
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... |