이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> answer(n, vector<int>(m, -1));
vector<int> numMinus(n, k);
priority_queue<pair<int, int>> pq;
for(int i = 0; i < n; i++)
pq.push({x[i][numMinus[i] - 1] + x[i][m - k + numMinus[i] - 1], i});
for(int i = 0; i < k * n / 2; i++){
int row = pq.top().second;
pq.pop();
numMinus[row]--;
if (numMinus[row] > 0)
pq.push({x[row][numMinus[row] - 1] + x[row][m - k + numMinus[row] - 1], row});
}
int plusPtr = 0, minusPtr = k - 1;
long long total = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < numMinus[i]; j++){
answer[i][j] = minusPtr;
minusPtr = (minusPtr == 0? k - 1 : minusPtr - 1);
total -= x[i][j];
}
for(int j = m - k + numMinus[i]; j < m; j++){
answer[i][j] = plusPtr;
plusPtr = (plusPtr == k - 1? 0 : plusPtr + 1);
total += x[i][j];
}
}
allocate_tickets(answer);
return total;
}
# | 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... |