이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#ifdef LOCAL
#include "grader.cpp"
#endif // LOCAL
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
using namespace std;
const int N = 2e6 + 10;
ll have[N], was[N], cnt[N], pl[N], pr[N];
ll find_maximum(int k, vector<vector<int>> x){
int n = x.size();
int m = x[0].size();
ll tans = 0;
vector<pair<int, int>> t;
for(int i = 0; i < n; ++i){
for(int j = m - 1; j >= m - k; --j)
tans += x[i][j];
// cout << i << endl;
for(int j = 0; j < k; ++j)
t.pb({-x[i][m - k + j] - x[i][j], i});
}
// cout << 1 << endl;
sort(t.begin(), t.end(), greater<pair<int, int>>());
for(int i = 0; i < n * k / 2; ++i)
++cnt[t[i].s], tans += t[i].f;
vector<int> t1;
for(int i = 0; i < n; ++i)
for(int j = 0; j < cnt[i]; ++j)
t1.pb(i);
vector<vector<int>> ans;
ans.resize(n);
for(int i = 0; i < n; ++i){
ans[i].resize(m);
for(int j = 0; j < m; ++j)
ans[i][j] = -1;
}
for(int i = 0; i < n; ++i)
pl[i] = 0, pr[i] = m - 1;
for(int i = 0; i < k; ++i){
for(int j = 0; j < n; ++j)
was[j] = 0;
for(int j = 0; j < n / 2; ++j)
was[t1[i + k * j]] = 1, ans[t1[i + k * j]][pl[t1[i + k * j]]++] = i;
for(int j = 0; j < n; ++j)
if(was[j] == 0)
ans[j][pr[j]--] = i;
}
allocate_tickets(ans);
return tans;
}
/*
2 3 2
0 2 5
1 1 3
7
0 -1 1
-1 1 0
4 2 1
5 9
1 4
3 6
2 7
12
-1 0
0 -1
0 -1
-1 0
*/
# | 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... |