이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<tickets.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod1 (1000000000+7)
#define mod (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 18;
// void allocate_tickets( std::vector<std::vector<int>> _x);
long long find_maximum(int k, vector<vector<int>> d){
ll ans = 0;
int n = d.size(), m = d[0].size();
vector<vector<int>> A(n, vector<int>(m, -1));
vector<array<int, 2>> a;
vector<array<int, 3>> big, small;
vector<int> H(n);
for(int i = 0; i < n; ++i){
H[i] = k;
for(int j = m - k; j < m; ++j){
ans += d[i][j];
a.pb({-d[i][j]-d[i][j-(m-k)], i});
}
}
sort(all(a), greater<array<int, 2>>());
int c = 0;
for(int i = 0; i < n*k/2; ++i, ++c){
if(H[a[c][1]] == 0){
--i;
continue;
}
ans += a[c][0];
H[a[c][1]]--;
}
for(int i = 0; i < n; ++i){
for(int j = m - 1; j >= m - H[i]; --j){
big.pb({d[i][j], i, j});
}
for(int j = 0; j < k - H[i]; ++j){
small.pb({d[i][j], i, j});
}
}
sort(all(big));
sort(all(small));
for(int turn = 0; turn < k; ++turn){
for(int j = turn * (n / 2); j < turn * (n / 2) + n / 2; ++j){
A[big[j][1]][big[j][2]] = turn;
A[small[j][1]][small[j][2]] = turn;
}
}
allocate_tickets(A);
return ans;
}
# | 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... |