이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void allocate_tickets(vector<vector<int> > s);
long long find_maximum(int k, vector<vector<int> > x){
int n = x.size(), m = x[0].size();
vector<vector<int> > s(n);
vector<int> num(n);
for(int i=0;i<n;i++){
s[i].resize(m);
for(int j=0;j<m;j++) s[i][j] = -1;
}
long long ans = 0;
priority_queue<pair<int, int> > pq;
for(int i=0;i<n;i++){
for(int j=k-1;j>=0;j--){
pq.push(make_pair(x[i][j]+x[i][m-1-(k-1-j)], i));
ans += -x[i][j];
}
}
for(int i=0;i<n*k/2;i++){
int val = pq.top().first, j = pq.top().second;
pq.pop();
ans += val;
num[j]++;
}
for(int i=0;i<k;i++){
vector<pair<int, int> > v;
for(int j=0;j<n;j++){
v.push_back(make_pair(num[j], j));
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
for(int j=0;j<n/2;j++){
int idx = v[j].second;
for(int k=m-1;k>=0;k--){
if(s[idx][k] == -1){
s[idx][k] = i;
break;
}
}
}
for(int j=n/2;j<n;j++){
int idx = v[j].second;
for(int k=0;k<m;k++){
if(s[idx][k] == -1){
s[idx][k] = i;
break;
}
}
}
}
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... |