# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
8258 | gs14004 | 막대기 (KOI13_game) | C++98 | 84 ms | 14248 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 <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long lint;
struct sti{int s,e,x;}a[100005], b[100005];
int atrack[100005], btrack[100005];
int fa[100005], fb[100005];
int n;
lint dp[100005][2],l;
bool cmp1(sti a, sti b){return a.s == b.s?(a.e < b.e) : (a.s < b.s);}
bool cmp2(sti a, sti b){return a.e == b.e?(a.s < b.s) : (a.e < b.e);}
lint f(int pos, int piv){
if(dp[pos][piv]) return dp[pos][piv];
if(piv == 0){
if(a[pos+1].s != a[pos].s) return l + abs(a[pos].e - a[pos].s);
else return dp[pos][piv] =
max(f(btrack[fa[pos+1]],1) + l + abs(a[pos].e - a[pos].s)
,f(pos+1,0) + abs(a[pos].e-a[pos].s) - abs(a[pos+1].e - a[pos+1].s));
}
else{
if(b[pos+1].e != b[pos].e) return l + abs(b[pos].e - b[pos].s);
else return dp[pos][piv] =
max(f(atrack[fb[pos+1]],0) + l + abs(b[pos].e - b[pos].s)
,f(pos+1,1) + abs(b[pos].e-b[pos].s) - abs(b[pos+1].e - b[pos+1].s));
}
}
# | 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... |