이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define sep ' '
const int MAXN = 1510;
int ptr[MAXN] , sum[MAXN] , L[MAXN] , R[MAXN] , F[MAXN][MAXN];
long long find_maximum(int k, vector<vector<int>> x) {
int n = x.size() , m = x[0].size();
ll ans = 0;
vector<pii> vec;
vector<vector<int>> answer;
for (int i = 0; i < n; i++) {
vector<int> row(m , 0);
for (int j = 0; j < k; j++) {
ans += x[i][m - k + j]; F[i][m - k + j] = 1;
vec.push_back({x[i][j] + x[i][m - k + j] , i});
}
answer.push_back(row);
}
sort(vec.begin(), vec.end());
for(int i = 0 ; i < n * k / 2 ; i++){
int val = vec[i].first , id = vec[i].second;
ans -= val;
F[id][ptr[id]] = -1; F[id][m - k + ptr[id]] = 0;
ptr[id]++;
}
for(int i = 0 ; i < n ; i++){
L[i] = 0; R[i] = m - 1;
for(int j = 0 ; j < m ; j++){
sum[i] += F[i][j];
answer[i][j] = -1;
}
}
for(int i = 0 ; i < k ; i++){
vector<pii> v;
for(int j = 0 ; j < n ; j++){
v.push_back({sum[j] , j});
}
sort(v.begin(), v.end());
for(int j = 0 ; j < n ; j++){
int id = v[j].second;
if(j < n / 2){
sum[id]++;
answer[id][L[id]++] = i;
}
else{
sum[id]--;
answer[id][R[id]--] = i;
}
}
}
allocate_tickets(answer);
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... |