이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <tickets.h>
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e3 + 5;
ll find_maximum(int k, vector<vector<int>> x){
int n = x.size();
int m = x[0].size();
vector<vector<int>> s(n, vector<int> (m, -1));
vector<pair<ll, int>> v;
vector<int> cnt(n);
ll ans = 0;
for(int i = 0; i < n; i++)
for(int j = k - 1, l = m - 1; j >= 0; j--, l--){
ans -= x[i][j];
v.emplace_back(x[i][j] + x[i][l], i);
}
sort(all(v));
for(int i = n * k / 2; i < n * k; i++){
auto& [t, y] = v[i];
ans += t; cnt[y]++;
}
priority_queue<pair<int, int>> mn, mx;
for(int i = 0; i < n; i++) {
mn.emplace(k - 1 - cnt[i], i);
mx.emplace(-(m - cnt[i]), i);
}
for(int i = 0; i < k; i++){
vector<pair<int, int>> tmn, tmx;
vector<int> chk(n);
for(int j = 0; j < n / 2; j++){
auto[t, y] = mn.top(); mn.pop();
assert(t >= 0);
s[y][t] = i; chk[y] = 1;
tmn.emplace_back(--t, y);
}
for(int j = 0; j < n / 2; j++){
auto[t, y] = mx.top(); mx.pop(); t = -t;
if(chk[y]) {
j--; tmn.emplace_back(-t, y); continue;
}
s[y][t] = i;
t++;
tmn.emplace_back(-t, y);
}
for(auto p : tmn) mn.emplace(p);
for(auto p : tmx) mx.emplace(p);
}
allocate_tickets(s);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:26:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
26 | auto& [t, y] = v[i];
| ^
tickets.cpp:39:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
39 | auto[t, y] = mn.top(); mn.pop();
| ^
tickets.cpp:45:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
45 | auto[t, y] = mx.top(); mx.pop(); t = -t;
| ^
# | 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... |