이 제출은 이전 버전의 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 pair<int, int> pii;
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));
vector <tiii> order;
for (int i=0;i<N;i++){
for (int k=0;k<K;k++) ans -= A[i][k];
for (int k=1;k<=K;k++) order.push_back(mt(A[i][M-k]+A[i][K-k], i, M-k));
}
sort(order.begin(), order.end());
vector <int> cnt(N, 0), lpt(N, 0);
for (int i=1;i<=K*N/2;i++){
auto [v, p, q] = order[order.size()-i];
ans += v; cnt[p]++;
}
for (int k=0;k<K;k++){
vector <pii> arr;
for (int i=0;i<N;i++) arr.push_back({-cnt[i], i});
sort(arr.begin(), arr.end());
for (int i=0;i<N/2;i++){
int t = arr[i].second;
assert(cnt[t] > 0);
answer[t][M-cnt[t]] = k;
cnt[t]--;
}
for (int i=N/2;i<N;i++){
int t = arr[i].second;
answer[t][lpt[t]++] = 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... |