답안 #40157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40157 2018-01-28T17:14:05 Z SpaimaCarpatilor Gap (APIO16_gap) C++14
89.0376 / 100
92 ms 5928 KB
#include "gap.h"
#include<bits/stdc++.h>

using namespace std;

long long x[100009];
const long long xmax = 1e18;

long long rand15 () {return rand () & 32767;}
long long rand30 () {return (rand15 () << 15LL) | rand15 ();}
long long rand60 () {return (rand30 () << 30LL) | rand30 ();}

long long findGap(int T, int N)
{
    srand (time (0));
    if (T == 1)
    {
        long long a = 0, b = xmax;
        for (int i = 1, j = N; i<=j; i ++, j --)
            MinMax (a, b, &x[i], &x[j]), a = x[i] + 1, b = x[j] - 1;
        long long ans = x[2] - x[1];
        for (int i=1; i<N; i++)
            if (x[i + 1] - x[i] > ans)
                ans = x[i + 1] - x[i];
        return ans;
    }
    long long mi, ma;
    MinMax (0, xmax, &mi, &ma);
    long long L = (ma - mi) / (N - 1);
    int nr = 0;
    long long st = mi + 1;
    x[1] = mi, nr = 1;
    while (st < ma)
    {
        long long dr = st + L - 1, y, z;
        if (dr >= ma) dr = ma - 1;
        MinMax (st, dr, &y, &z);
        if (y != -1) x[++nr] = y;
        if (y != z) x[++nr] = z;
        st = dr + 1;
    }
    x[++nr] = ma;
    long long ans = x[2] - x[1];
    for (int i=2; i<nr; i++)
        ans = max (ans, x[i + 1] - x[i]);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 2 ms 5928 KB Output is correct
12 Correct 1 ms 5928 KB Output is correct
13 Correct 1 ms 5928 KB Output is correct
14 Correct 2 ms 5928 KB Output is correct
15 Correct 1 ms 5928 KB Output is correct
16 Correct 13 ms 5928 KB Output is correct
17 Correct 12 ms 5928 KB Output is correct
18 Correct 8 ms 5928 KB Output is correct
19 Correct 14 ms 5928 KB Output is correct
20 Correct 9 ms 5928 KB Output is correct
21 Correct 58 ms 5928 KB Output is correct
22 Correct 54 ms 5928 KB Output is correct
23 Correct 56 ms 5928 KB Output is correct
24 Correct 71 ms 5928 KB Output is correct
25 Correct 49 ms 5928 KB Output is correct
26 Correct 50 ms 5928 KB Output is correct
27 Correct 48 ms 5928 KB Output is correct
28 Correct 48 ms 5928 KB Output is correct
29 Correct 53 ms 5928 KB Output is correct
30 Correct 45 ms 5928 KB Output is correct
31 Correct 0 ms 5928 KB Output is correct
32 Correct 0 ms 5928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 2 ms 5928 KB Output is correct
12 Correct 2 ms 5928 KB Output is correct
13 Correct 2 ms 5928 KB Output is correct
14 Correct 1 ms 5928 KB Output is correct
15 Correct 1 ms 5928 KB Output is correct
16 Correct 22 ms 5928 KB Output is correct
17 Correct 19 ms 5928 KB Output is correct
18 Correct 16 ms 5928 KB Output is correct
19 Correct 20 ms 5928 KB Output is correct
20 Partially correct 10 ms 5928 KB Partially correct
21 Correct 68 ms 5928 KB Output is correct
22 Correct 74 ms 5928 KB Output is correct
23 Correct 73 ms 5928 KB Output is correct
24 Correct 74 ms 5928 KB Output is correct
25 Correct 67 ms 5928 KB Output is correct
26 Correct 70 ms 5928 KB Output is correct
27 Correct 69 ms 5928 KB Output is correct
28 Correct 92 ms 5928 KB Output is correct
29 Correct 74 ms 5928 KB Output is correct
30 Partially correct 41 ms 5928 KB Partially correct
31 Correct 0 ms 5928 KB Output is correct
32 Correct 0 ms 5928 KB Output is correct