이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define sep ' '
#define debug(x) cerr << #x << ": " << x << endl;
const int MAXN = 1500 + 10;
int n, m, PL[MAXN], PR[MAXN];
ll ans;
ll find_maximum(int k, vector<vector<int>> A) {
n = A.size();
m = A[0].size();
for (int i = 0; i < n; i++)
sort(all(A[i]));
vector<vector<int>> res;
res.resize(n);
for (auto& e : res) {
e.resize(m);
for (int& x : e)
x = -1;
}
for (int i = 0; i < n; i++)
PL[i] = 0, PR[i] = m - 1;
for (int t = 0; t < k; t++) {
vector<pair<int, pll>> poss;
for (int i = 0; i < n; i++) {
poss.push_back({i, {A[i][PL[i]], A[i][PR[i]]}});
ans -= A[i][PL[i]];
}
sort(all(poss), [] (const pair<int, pll>& a, const pair<int, pll>& b) {
return a.Y.Y + a.Y.X < b.Y.Y + b.Y.Y;
});
/*for (auto [ind, wtf] : poss) {
cerr << ind << sep << wtf.X << sep << wtf.Y << endl;
}
*/
for (int i = 0; i < n / 2; i++) {
int ind = poss[i].X;
res[ind][PL[ind]++] = t;
}
for (int i = n / 2; i < n; i++) {
int ind = poss[i].X;
res[ind][PR[ind]--] = t;
ans += poss[i].Y.X + poss[i].Y.Y;
}
}
allocate_tickets(res);
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... |