이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "tickets.h"
using namespace std;
typedef long long llint;
typedef pair <int, int> pi;
const int MAXN = 1505;
int n, m, k;
int bio[MAXN][MAXN];
vector <pi> a[MAXN];
vector < pair <llint, pi> > v;
llint find_maximum (int K, vector < vector <int> > A) {
k = K;
n = A.size();
m = A[0].size();
memset(bio, -1, sizeof bio);
llint res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i].push_back({A[i][j], j});
}
sort(a[i].begin(), a[i].end());
for (int j = 0; j < k; j++) {
bio[i][m - 1 - j] = 1;
res += a[i][m - 1 - j].first;
llint val = a[i][j].first + a[i][m - (k - j)].first;
v.push_back({val, {i, j}});
}
}
sort(v.begin(), v.end());
for (int i = 0; i < n * k / 2; i++) {
llint val = v[i].first;
int row = v[i].second.first, col = v[i].second.second;
res -= val;
bio[row][m - (k - col)] = -1;
bio[row][col] = 0;
}
vector < vector <int> > sol;
vector <int> tmp(m, 0);
for (int i = 0; i < n; i++) sol.push_back(tmp);
int curr = 0;
for (int i = 0; i < n; i++) {
int nula = 0, jen = 0;
for (int j = 0; j < m; j++) {
if (bio[i][j] == 0) nula++;
if (bio[i][j] == 1) jen++;
if (bio[i][j] != -1) {
sol[i][a[i][j].second] = curr % k;
curr++;
} else {
sol[i][a[i][j].second] = -1;
}
}
curr += nula;
}
allocate_tickets(sol);
return res;
}
# | 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... |