Submission #205386

# Submission time Handle Problem Language Result Execution time Memory
205386 2020-02-28T18:29:26 Z awlintqaa Shortcut (IOI16_shortcut) C++14
0 / 100
6 ms 632 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 200
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf= 4e18;
const ld pai=acos(-1);
#include "shortcut.h"
ll n,cost;
ll a[100009],d[100009];
ll dis(ll x,ll y){return abs(a[x]-a[y]);}
ll solve(int x,int y){
        if(dis(x,y)<cost)return inf;
        ll bef=0,aft=0;
        for(int i=0;i<=x;i++)bef=max(bef,dis(x,i)+d[i]);
        for(int i=y;i<n;i++) aft=max(aft,dis(y,i)+d[i]);
        ll ans=bef+aft+cost;
        for(int i=x+1;i<=y-1;i++){
                ans=max(ans,bef+ min(dis(i,x),dis(i,y)+cost)+d[i]);
                ans=max(ans,aft+ min(dis(i,y),dis(i,x)+cost)+d[i]);
        }
        ll xxx=inf;
        for(int i=0;i<=x;i++){
                ans=max(ans,a[i]+d[i]-xxx);
                xxx=min(xxx,a[i]-d[i]);
        }xxx=inf;
        for(int i=y;i<n;i++){
                ans=max(ans,a[i]+d[i]-xxx);
                xxx=min(ans,a[i]-d[i]);
        }
        for(int i=x;i<=y;i++){
                for(int j=i+1;j<=y;j++){
                        ans=max(ans,min(dis(i,j),dis(y,j)+dis(x,i)+cost)+d[i]+d[j]);
                }
        }
        return ans;
}
ll find_shortcut(int N, vi l, vi D, int c){
        n=N;cost=c;
        for(int i=0;i<n;i++)d[i]=D[i];
        for(int i=1;i<n;i++){
                a[i]=a[i-1]+l[i-1];
        }
        ll ans=0;
        for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                        ans=max(ans,dis(i,j)+d[i]+d[j]);
                }
        }
        for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                        ans=min(ans,solve(i,j));
                }
        }
        return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB n = 4, 80 is a correct answer
2 Correct 5 ms 376 KB n = 9, 110 is a correct answer
3 Correct 6 ms 632 KB n = 4, 21 is a correct answer
4 Correct 5 ms 376 KB n = 3, 4 is a correct answer
5 Correct 5 ms 376 KB n = 2, 62 is a correct answer
6 Correct 5 ms 256 KB n = 2, 3 is a correct answer
7 Correct 5 ms 376 KB n = 3, 29 is a correct answer
8 Correct 5 ms 376 KB n = 2, 3 is a correct answer
9 Correct 5 ms 376 KB n = 2, 3 is a correct answer
10 Correct 5 ms 376 KB n = 2, 2000000001 is a correct answer
11 Correct 5 ms 256 KB n = 2, 3000000000 is a correct answer
12 Correct 5 ms 376 KB n = 3, 3000000000 is a correct answer
13 Correct 5 ms 256 KB n = 3, 3000000000 is a correct answer
14 Correct 5 ms 376 KB n = 4, 3000000001 is a correct answer
15 Correct 5 ms 256 KB n = 4, 4000000000 is a correct answer
16 Correct 5 ms 376 KB n = 5, 4000000000 is a correct answer
17 Correct 5 ms 256 KB n = 10, 1000000343 is a correct answer
18 Correct 5 ms 376 KB n = 10, 3189 is a correct answer
19 Correct 5 ms 376 KB n = 10, 7000000000 is a correct answer
20 Correct 5 ms 376 KB n = 5, 12 is a correct answer
21 Correct 5 ms 376 KB n = 5, 25 is a correct answer
22 Correct 5 ms 256 KB n = 2, 122 is a correct answer
23 Incorrect 5 ms 376 KB n = 10, incorrect answer: jury 117 vs contestant 109
24 Halted 0 ms 0 KB -