이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void allocate_tickets( std::vector<std::vector<int>> _x);
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> anss(n,vector<int>(m,-1));
ll ans=0;
vector<int> status(n,k-1);
priority_queue<pair<ll,ll>> deltaq;
for(int i=0;i<n;i++){
for(int j=0;j<k;j++)ans-=x[i][j];
deltaq.emplace(x[i][k-1]+x[i][m-1],i);
}
for(int i=0;i<(n/2)*k;i++){
auto [change,idx] = deltaq.top();deltaq.pop();
ans+=change;
status[idx]--;
if(status[idx]==-1)continue;
deltaq.emplace(x[idx][status[idx]]+x[idx][m-k+status[idx]],idx);
}
int round = 0;
for(int i=0;i<n;i++){
for(int j=0;j<=status[i];j++)anss[i][j]=(round++)%k;
int t = round;
for(int j=m-k+status[i]+1;j<m;j++)anss[i][j]=(t++)%k;
}
allocate_tickets(anss);
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... |