이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define X first
#define Y second
#define ALL(v) v.begin(),v.end()
#define SZ(a) ((int)a.size())
#define pb push_back
const ll INF=1e18;
ll find_maximum(int k, vector<vector<int>> x)
{
int n = x.size();
int m = x[0].size();
int tar=n*k/2;
vector<vector<ll>> dp(n+1,vector<ll>(tar+1,-INF)),take(n+1,vector<ll>(k+1,0));
vector<vector<int>> answer(n,vector<int>(m,-1));
for(int i=1;i<=n;++i)
{
for(int j=0;j<k;++j)
take[i][0]-=x[i-1][j];
for(int j=1;j<=k;++j)
take[i][j]=take[i][j-1]+x[i-1][k-j]+x[i-1][m-j];
}
dp[0][tar]=0;
for(int i=1;i<=n;++i)
for(int j=0;j<=tar;++j)
for(int t=0;t<=k&&j+t<=tar;++t)
dp[i][j]=max(dp[i][j],dp[i-1][j+t]+take[i][t]);
int nw=0;
for(int i=n;i>=1;--i)
{
for(int t=0;t<=k;++t)
if(dp[i][nw]==dp[i-1][nw+t]+take[i][t])
{
for(int p=0;p<k-t;++p)
answer[i-1][p]=0;
for(int p=m-t;p<m;++p)
answer[i-1][p]=0;
nw+=t;
break;
}
}
allocate_tickets(answer);
return dp[n][0];
}
# | 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... |