This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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][ + j]; F[i][ + j] = 1;
vec.push_back({x[i][j] + x[i][ + 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][ + 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... |