| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 300346 | daniel920712 | Carnival Tickets (IOI20_tickets) | C++14 | 1 ms | 256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "tickets.h"
#include <vector>
#include <algorithm>
using namespace std;
struct A
{
int where;
int con;
}tt[1505];
vector < vector < int > > answer;
vector < int > row;
vector< vector<int> > all;
bool have[1505][1505];
int DP[1505][1505];
int n,m;
long long F(long long here,long long con)
{
if(con>n/2) return -1e18;
if(here==n&&con!=n/2) return -1e18;
if(here==n) return 0;
if(have[here][con]) return DP[here][con];
have[here][con]=1;
DP[here][con]=max(F(here,con+1)+all[here][m-1],F(here,con)-all[here][0]);
return DP[here][con];
}
void F2(long long here,long long con)
{
if(here==n&&con!=n/2) return;
if(F(here,con+1)+all[here][m-1]>F(here,con)-all[here][0])
{
F2(here,con+1);
answer[here][m-1]=0;
}
else
{
F2(here,con);
answer[here][0]=0;
}
}
long long find_maximum(int k,vector< vector<int> > x)
{
all=x;
n=x.size();
m=x[0].size();
int i,j,t,ok,now;
long long ans=0;
for(i=0;i<m;i++) row.push_back(-1);
for(i=0;i<n;i++) answer.push_back(row);
if(k==1)
{
for(int i=0;i<n;i++) answer[i][0]=0;
ans=F(0,0);
}
allocate_tickets(answer);
return ans;
}
Compilation message (stderr)
| # | 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... | ||||
