이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define mt make_tuple
typedef tuple<int, int, int> tiii;
typedef long long lld;
lld find_maximum(int K, vector<vector<int>> A)
{
int N = A.size();
int M = A[0].size();
lld ans = 0;
vector<vector<int>> answer(N, vector<int>(M, -1));
priority_queue <tiii> que;
for (int i=0;i<N;i++){
for (int k=0;k<K;k++) ans -= A[i][k], answer[i][k] = -2;
que.push(mt(A[i][M-1]+A[i][K-1], i, M-1));
}
for (int k=0;k<K;k++){
queue <tiii> todo;
for (int i=0;i<N;i+=2){
auto t = que.top(); que.pop();
auto [v, p, q] = t;
answer[p][K-(M-q)] = -1; answer[p][q] = k;
ans += v;
if (M-q > k && q > 0) todo.push(mt(A[p][q-1]+A[p][K-(M-q)-1], p, q-1));
else if (q > 0) que.push(mt(A[p][q-1]+A[p][K-(M-q)-1], p, q-1));
}
while (!todo.empty()){
auto q = todo.front(); todo.pop();
que.push(q);
}
}
for (int i=0;i<N;i++){
// for (int j=0;j<M;j++) debug("%d ", answer[i][j]); debug("\n");
vector <bool> vis(K, 0);
for (int j=M,k=K-1;j--;){
if (answer[i][j] >= 0) vis[answer[i][j]] = 1;
else if (answer[i][j] == -2){
while (k >= 0 && vis[k]) k--;
assert(k >= 0);
answer[i][j] = k;
}
}
}
allocate_tickets(answer);
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... |