# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
48512 |
2018-05-15T09:47:00 Z |
leehosu01 |
수족관 3 (KOI13_aqua3) |
C++17 |
|
1000 ms |
58184 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cut[300002],N,K;
ll counte(int loc)
{
ll tot=0,dep=1ll<<54;
for(int i=loc;i<N-2;i+=2)
tot+=(cut[i+2]-cut[i])*(dep=min(dep,cut[i+1]));
dep=1ll<<54;
for(int i=loc;i>0;i-=2)
tot+=(cut[i]-cut[i-2])*(dep=min(dep,cut[i-1]));
return tot;
}
map<pair<pair<ll,ll>,int>,ll>MMP;
ll pro(int l,int r,ll lo,int k)
{
// printf("%d %d %lld %d\n",r,l,lo,k);
if(MMP.find({{r,l},k})!=MMP.end())return MMP[{{r,l},k}];
if(r<l||!k)return 0;
ll Mi=r,maxx=0;
for(int i=r+2;i<=l;i+=2)
if(cut[i]<cut[Mi])Mi=i;
for(int i=0;i<=k;i++)maxx=max(maxx,pro(l,Mi-2,cut[Mi],i)+pro(Mi+2,r,cut[Mi],k-i));
// printf("%lld %lld \n",cut[Mi]-lo,cut[r-1]-cut[l-1]);
// printf("%d %d %lld %d::%lld \n",r,l,lo,k,maxx+(cut[Mi]-lo)*(cut[r-1]-cut[l-1]));
return MMP[{{r,l},k}]=maxx+(cut[Mi]-lo)*(cut[r-1]-cut[l-1]);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>N;
int i;
ll aA[2];
for(i=0;i<N;i++)
{
cin>>aA[0]>>aA[1];
cut[i]=aA[i&1];
}
cin>>K;
printf("%lld",pro(1,N-1,0,K));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
9884 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
57920 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
58184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
58184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |