이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "tickets.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int INF = 5e8, N = 1e5+10, M = 998244353, LOG = 16;
const ll LINF = 1e18;
ll find_maximum(int k, vector<vector<int>> x) {
ll tot_sum = 0;
priority_queue<pair<int, int>> pq;
int n = x.size(), m = x[0].size();
vector<int> lp(n, k-1), rp(n, m-1);
for (int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
tot_sum -= x[i][j];
}
pq.push({x[i][lp[i]] + x[i][rp[i]], i});
}
int to_swap = (n * k) / 2;
vector<vector<int>> b(n, vector<int>(m, -1));
while(!pq.empty() and to_swap) {
auto [inc, c] = pq.top(); pq.pop();
tot_sum += inc;
to_swap--;
b[c][rp[c]] = 1;
lp[c]--; rp[c]--;
if(lp[c] >= 0 and n-1-rp[c] < k) {
pq.push({x[c][lp[c]] + x[c][rp[c]], c});
}
}
assert(to_swap == 0);
for(int i = 0; i < n; i++) {
int cnt = (i&1 ? k-1 : 0);
for (int j = 0; j < m; j++) {
if(b[i][j] == 1 or j <= lp[i]) {
b[i][j] = (i&1 ? cnt-- : cnt++);
}
}
}
allocate_tickets(b);
return tot_sum;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:31:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
31 | auto [inc, c] = pq.top(); pq.pop();
| ^
# | 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... |