이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <algorithm>
#include "tickets.h"
using namespace std;
#define x first
#define y second
typedef std::pair<int,int> pii; typedef long long ll;
template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
ll find_maximum(int K, vector<vector<int>> A) {
int N = A.size(), M = A[0].size();
ll tot = 0;
vector<pii> S;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < K; ++j) {
tot += A[i][j+M-K];
S.push_back({A[i][j] + A[i][j+M-K], i});
}
}
nth_element(S.begin(), S.begin() + N*K/2, S.end());
vector<int> CntLo(N, 0), CntHi(N);
for (int i = 0; i < N*K/2; ++i) {
tot -= S[i].x;
CntLo[S[i].y]++;
}
for (int i = 0; i < N; ++i) CntHi[i] = K - CntLo[i];
vector2<int> T(N, M, -1);
for (int i = 0; i < K; ++i) {
int lo = N/2, hi = N/2;
for (int j = 0; j < N; ++j) {
hi -= CntLo[j] == 0;
lo -= CntHi[j] == 0;
}
for (int j = 0; j < N; ++j) {
if (CntLo[j] == 0 || lo == 0) {
T[j][M-CntHi[j]] = i;
hi -= (CntLo[j] != 0);
--CntHi[j];
} else {
--CntLo[j];
T[j][CntLo[j]] = i;
lo -= (CntHi[j] != 0);
}
}
}
allocate_tickets(T);
return tot;
}
# | 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... |