이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "tickets.h"
using namespace std;
int cnt[1505];
int n , m ,k;
vector<vector<int>>a;
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][0] - a[i][m - k] , i);
} /// --k
for(int i = 0; i < n * k / 2; ++i){
auto x = pq.top(); pq.pop();
int q = x.second;
ans += x.first;
if(++cnt[q] < k) pq.emplace(-a[q][cnt[q]] - a[q][m - k + cnt[q]] , q);
}
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... |