이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
using pp=pair<int, int>;
using ll=long long;
int n, m, k;
int prog[1510];
priority_queue<pp> pq;
ll ans;
int pg(auto &x, int i, int j) {
return -x[i][j]-x[i][m-k+j];
}
int nc[1510];
#include <cassert>
ll find_maximum(int k_, vector<vector<int>> x) {
n = x.size(); m = x[0].size(); k = k_;
for(int i=0; i<n; ++i) for(int j=m-k; j<m; ++j) ans += x[i][j];
for(int i=0; i<n; ++i) pq.emplace(pg(x, i, 0), i);
for(int cnt=n*k/2; cnt--;) {
auto [tv, ti] = pq.top(); pq.pop();
ans += tv;
if (++prog[ti] != k) {
pq.emplace(pg(x, ti, prog[ti]), ti);
}
}
int lmax = -1, rmin = 1e9;
for(int i=0; i<n; ++i) {
int t = prog[i];
if (t) lmax = max(lmax, x[i][t-1]);
if (t != k) rmin = min(rmin, x[i][m-k+t]);
}
assert (lmax <= rmin);
for(int i=0; i<n; ++i) {
fill(x[i].begin(), x[i].end(), -1);
int t = prog[i];
int ai = 0, bi = m-1;
for(int j=0; j<k; ++j) {
if (ai < t && nc[j] != n/2) {
x[i][ai++] = j;
++nc[j];
} else {
x[i][bi--] = j;
}
}
}
allocate_tickets(x);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp:15:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts'
15 | int pg(auto &x, int i, int j) {
| ^~~~
# | 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... |