이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define maxn 1515
#define pii pair<int,int>
int ini[maxn];
int fim[maxn];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(m);
for (int j = 0; j < m; j++) {
row[j] = -1;
}
answer.push_back(row);
}
long long ans = 0;
set<pii> S;
for(int i=0;i<n;i++){
for(int j=m-k;j<m;j++){
ans += x[i][j];
answer[i][j] = -2;
}
ini[i] = 0;
fim[i] = m-k;
S.insert({x[i][ini[i]] + x[i][fim[i]],i});
}
for(int i=0;i<(k*n)/2;i++){
pii u = *S.begin();
S.erase(S.begin());
ans -= u.first;
int id = u.second;
answer[id][ini[id]] = -3;
ini[id]++;
answer[id][fim[id]] = -1;
fim[id]++;
if(fim[id] < m){
S.insert({x[id][ini[id]] + x[id][fim[id]],id});
}
}
int cur = 0, curcur = 0;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(answer[i][j] == -3){
answer[i][j] = cur;
cur = (cur+1) % k;
curcur = cur;
}
if(answer[i][j] == -2){
answer[i][j] = curcur;
curcur = (curcur+1) % k;
}
}
//cur = curcur;
}
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... |