이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k, vector<vector<int> > x) {
int n = x.size();
int m = x[0].size();
vector<long long> dp (n);
vector<vector<bool> > bt (n, vector<bool> (n, 0));
vector<vector<pair<long long, int> > > ord (n, vector<pair<long long, int> > (m));
vector<vector<int> > ans (n, vector<int> (m, -1));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)
ord[i][j] = make_pair(x[i][j], j);
sort(ord[i].begin(), ord[i].end());
// printf("Para pilha %d, fundo = %d, topo = %d\n", i, ord[i][0].first, ord[i][m - 1].first);
}
for(int i = 0; i < n; i++){
for(int j = n / 2; j >= 0; j--){
dp[j] = dp[j] - ord[i][0].first;
if(j != 0 && dp[j - 1] + ord[i][m - 1].first > dp[j]) dp[j] = dp[j - 1] + ord[i][m - 1].first, bt[i][j] = 1;
// printf("dp[%d][%d] = %d\n", i, j, dp[j]);
}
}
int curI = n - 1, curJ = n / 2;
while(curI >= 0){
if(bt[curI][curJ]) curJ--, ans[curI][ord[curI][m - 1].second] = 0;
else ans[curI][ord[curI][0].second] = 0;
curI--;
}
allocate_tickets(ans);
return dp[n / 2];
}
# | 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... |