답안 #134801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134801 2019-07-23T09:34:36 Z ckodser Shortcut (IOI16_shortcut) C++14
0 / 100
2 ms 376 KB
#include "shortcut.h"
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double

using namespace :: std;
const ll maxn=510;
const ll inf=1e17+900;

ll pos[maxn];
ll farr[maxn];
ll farl[maxn];
ll dr[maxn];
ll dl[maxn];
ll c,n,ans=inf;
vector<ll> l;
vector<ll> d;


ll ERT[maxn][maxn];

ll findANS(ll i,ll j){
    if(ERT[i][j]!=0)return ERT[i][j];
    ll res=max(dr[j],dl[i]);
    ll sdi=d[i];
    ll sdj=d[j];
    d[j]=farr[j];
    d[i]=farl[i];
    ll tol=c+pos[j]-pos[i];
    
    for(ll u=i;u<=j;u++){
	for(ll v=u+1;v<=j;v++){
	    res=max(res,(ll)d[v]+(ll)d[u]+min(pos[v]-pos[u],tol-(pos[v]-pos[u])));
	}
    }
    d[j]=sdj;
    d[i]=sdi;
    ans=min(ans,res);
    ERT[i][j]=res;
    return res;
}
long long find_shortcut(int N,vector<int> L,vector<int> D, int C)
{
    n=N;
    c=C;
    for(auto v:L){
	l.pb(v);
    }
    for(auto v:D){
	d.pb(v);
    }

    pos[0]=0;
    for(ll i=1;i<n;i++){
	pos[i]=pos[i-1]+l[i-1];
    }
    dl[0]=d[0];
    farl[0]=d[0];
    for(ll i=1;i<n;i++){
	farl[i]=max(d[i],farl[i-1]+l[i-1]);
	dl[i]=max(dl[i-1],farl[i-1]+l[i-1]+d[i]);
    }
    dr[n-1]=d[n-1];
    farr[n-1]=d[n-1];
    for(ll i=n-2;i>=0;i--){
    	farr[i]=max((ll)d[i],farr[i+1]+l[i]);
	dr[i]=max(dr[i+1],farr[i+1]+l[i]+d[i]);
    }
    ll pj=n-1;
    for(ll i=n-2;i>=0;i--){
	while(pj>i+1 && findANS(i,pj)>findANS(i,pj-1))pj--;
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n = 4, 80 is a correct answer
2 Correct 2 ms 376 KB n = 9, 110 is a correct answer
3 Correct 2 ms 376 KB n = 4, 21 is a correct answer
4 Correct 2 ms 376 KB n = 3, 4 is a correct answer
5 Incorrect 2 ms 376 KB n = 2, incorrect answer: jury 62 vs contestant 100000000000000896
6 Halted 0 ms 0 KB -