이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
#include "tickets.h"
const int maxn = 1505;
const ll INF = 1e18;
ll dp[maxn][maxn];
long long find_maximum(int k, std::vector<std::vector<int>> x) {
int n = x.size();
int m = x[0].size();
vector<vector<int>> ans(n, vector<int>(m, -1));
ll c = 0;
vector<int> l(n, 0), r(n, m - 1);
while(k--){
for(int i = 0; i <= n; i++) for(int j = 0; j <= n / 2; j++) dp[i][j] = -INF;
dp[0][0] = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j <= n / 2; j++){
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] - x[i][l[i]]);
dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + x[i][r[i]]);
}
}
c += dp[n][n / 2];
int cnt = n / 2;
for(int i = n - 1; i >= 0; i--){
if(dp[i][cnt] - x[i][l[i]] == dp[i + 1][cnt]){
ans[i][l[i]] = k;
l[i] ++;
}
else{
ans[i][r[i]] = k;
r[i] --;
cnt--;
}
}
}
allocate_tickets(ans);
return c;
}
# | 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... |