답안 #433028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433028 2021-06-18T18:12:18 Z MarcoMeijer Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 332 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
#define sz size()
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = 1e18;

ll n, c;
vll l, d;

bool possible(ll dist) {
    ll minSum=0, maxSum=INF, minDif=0, maxDif=INF;
    RE(i,n) RE(j,i) {
        ll curDist = d[i]+d[j]+l[i]-l[j];
        if(curDist <= dist) continue;
        ll over = dist - d[i] - d[j] - c;
        minDif = max(minDif, l[i]-l[j]-over);
        maxDif = min(maxDif, l[i]-l[j]+over);
        minSum = max(minSum, l[i]+l[j]-over);
        maxSum = min(maxSum, l[i]+l[j]+over);
    }

    int j1 = 0, j2 = 0;
    REP(i,1,n) {
        ll curDif, curSum;
        while(j1+1 < i) {
            curDif = l[i]-l[j1];
            if(curDif > maxDif)
                j1++;
            else
                break;
        }
        while(j2+1 < i) {
            curSum = l[i]+l[j2];
            if(curSum < minSum)
                j2++;
            else
                break;
        }

        curDif = l[i]-l[j1];
        curSum = l[i]+l[j1];
        if(minDif <= curDif && curDif <= maxDif && minSum <= curSum && curSum <= maxSum)
            return true;

        curDif = l[i]-l[j2];
        curSum = l[i]+l[j2];
        if(minDif <= curDif && curDif <= maxDif && minSum <= curSum && curSum <= maxSum)
            return true;
    }
    return false;
}

ll find_shortcut(int n_, vi l_, vi d_, int c_) {
    n = n_; c=c_;
    l.pb(0);
    FOR(i,l_)
        l.pb(i);
    FOR(i,d_) d.pb(i);
    REP(i,1,n) l[i]+=l[i-1];

    ll lb=0, ub=INF;
    while(lb != ub) {
        ll mid=(lb+ub)/2;
        if(possible(mid)) ub=mid;
        else lb=mid+1;
    }

    return lb;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n = 4, 80 is a correct answer
2 Correct 0 ms 204 KB n = 9, 110 is a correct answer
3 Correct 1 ms 204 KB n = 4, 21 is a correct answer
4 Correct 0 ms 204 KB n = 3, 4 is a correct answer
5 Correct 1 ms 204 KB n = 2, 62 is a correct answer
6 Correct 0 ms 204 KB n = 2, 3 is a correct answer
7 Correct 0 ms 204 KB n = 3, 29 is a correct answer
8 Correct 0 ms 204 KB n = 2, 3 is a correct answer
9 Correct 0 ms 204 KB n = 2, 3 is a correct answer
10 Correct 1 ms 204 KB n = 2, 2000000001 is a correct answer
11 Correct 1 ms 204 KB n = 2, 3000000000 is a correct answer
12 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
13 Correct 0 ms 204 KB n = 3, 3000000000 is a correct answer
14 Correct 0 ms 204 KB n = 4, 3000000001 is a correct answer
15 Correct 0 ms 204 KB n = 4, 4000000000 is a correct answer
16 Correct 0 ms 204 KB n = 5, 4000000000 is a correct answer
17 Correct 0 ms 204 KB n = 10, 1000000343 is a correct answer
18 Correct 1 ms 204 KB n = 10, 3189 is a correct answer
19 Correct 1 ms 204 KB n = 10, 7000000000 is a correct answer
20 Correct 0 ms 204 KB n = 5, 12 is a correct answer
21 Correct 0 ms 204 KB n = 5, 25 is a correct answer
22 Correct 1 ms 332 KB n = 2, 122 is a correct answer
23 Correct 0 ms 204 KB n = 10, 117 is a correct answer
24 Incorrect 0 ms 204 KB n = 10, incorrect answer: jury 336 vs contestant 367
25 Halted 0 ms 0 KB -