이 제출은 이전 버전의 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<ll, 2>> a;
set<array<int, 3>> big, small;
vector<int> H(n), L(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<ll, 2>>());
for(int i = 0; i < n*k/2; ++i){
ans += a[i][0];
H[a[i][1]]--;
}
for(int i = 0; i < n; ++i) L[i] = k - H[i];
for(int i = 0; i < n; ++i){
if(H[i])
big.insert({-d[i][m - k], i, m - k});
if(L[i])
small.insert({-d[i][0], i, 0});
}
for(int turn = 0; turn < k; ++turn){
vector<bool> used(n);
set<array<int, 3>> bt, st;
int c = 0;
for(auto x: big){
if(used[x[1]] || c == n / 2){
bt.insert(x);
continue;
}
used[x[1]] = 1;
A[x[1]][x[2]] = turn;
H[x[1]]--;
c++;
if(H[x[1]] > 0)
bt.insert({d[x[1]][m - H[x[1]]], x[1], m - H[x[1]]});
}
c = 0;
for(auto x: small){
if(used[x[1]] || c == n / 2){
st.insert(x);
continue;
}
used[x[1]] = 1;
A[x[1]][x[2]] = turn;
L[x[1]]--;
c++;
if(L[x[1]] > 0)
st.insert({d[x[1]][L[x[1]]], x[1], L[x[1]]});
}
big.swap(bt);
small.swap(st);
}
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... |