이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define mp(x...) array<int, 2>({x})
#define int int64_t
using namespace std;
//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
constexpr static int INF = 1e15;
constexpr static int MXN = 1505;
int prefix[MXN][MXN], suffix[MXN][MXN];
void allocate_tickets(vector<vector<int32_t>> s);
int find_maximum(int32_t _k, vector<vector<int32_t>> x)
{
int k = _k;
int n = x.size();
int m = x[0].size();
vector<array<int, 2>> v;
for (int i = 0; i < n; i++)
for (int j = 0; j < k; j++)
v.pb({x[i][j] + x[i][m-k+j], i});
sort(v.begin(), v.end());
int current_count = k*n/2;
vector<vector<int32_t>> s(n, vector<int32_t>(m,-1));
vector<array<int, 2>> bounds(n, {0, m-1}); // Left right
vector<array<int, 2>> counts; // Small count, n
vector<int> tcounts(n, 0);
for (int i = 0; i < n; i++)
counts.pb({0, i});
int total_used = 0;
for (int i = 0; total_used < n*k/2; i++)
{
if (tcounts[v[i][1]] >= k)
continue;
total_used++;
tcounts[v[i][1]]++;
counts[v[i][1]][0]++;
}
sort(counts.begin(), counts.end());
int sum = 0;
for (int i = 0; i < k; i++)
{
for (int j = n/2; j < n; j++)
{
sum -= x[counts[j][1]][bounds[counts[j][1]][0]];
s[counts[j][1]][bounds[counts[j][1]][0]++] = i;
counts[j][0]--;
}
for (int j = 0; j < n/2; j++)
{
sum += x[counts[j][1]][bounds[counts[j][1]][1]];
s[counts[j][1]][bounds[counts[j][1]][1]--] = i;
}
sort(counts.begin(), counts.end());
}
debug("b");
allocate_tickets(s);
return sum;
}
컴파일 시 표준 에러 (stderr) 메시지
tickets.cpp: In function 'int64_t find_maximum(int32_t, std::vector<std::vector<int> >)':
tickets.cpp:30:6: warning: unused variable 'current_count' [-Wunused-variable]
30 | int current_count = k*n/2;
| ^~~~~~~~~~~~~
# | 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... |