Submission #109796

# Submission time Handle Problem Language Result Execution time Memory
109796 2019-05-08T04:59:38 Z DodgeBallMan Gap (APIO16_gap) C++14
100 / 100
78 ms 3308 KB
#include "gap.h"
#include <bits/stdc++.h>

using namespace std;

long long n;
vector<long long> ans;
long long findGap( int T, int N ) {
    long long ret = 0;
    n = ( long long )N;
    long long l = 0, r = 1e18, mn, mx;
    if( T == 1 ) {
        for( int i = 0 ; i < ( n + 1 ) / 2 ; i++ ) {
            MinMax( l, r, &mn, &mx );
            ans.emplace_back( mn );
            if( mn != mx ) ans.emplace_back( mx );
            l = mn + 1, r = mx - 1;
        }
        sort( ans.begin(), ans.end() );
        for( int i = 0 ; i < ( int )ans.size() - 1 ; i++ ) ret = max( ret, ans[i+1] - ans[i] );
        return ret;
    }
    MinMax( 0, 1e18, &l, &r );
    long long seg = ( r - l ) / ( n - 1 );
    ans.emplace_back( l );
    for( long long i = 0 ; i < n - 1 ; i++ ) {
        long long L = l + 1 + i * seg, R;
        if( i == n - 2 ) R = r;
        else R = l + ( i + 1 ) * seg;
        MinMax( L, R, &mn, &mx );
        if( mn != -1 && mx != -1 ) ans.emplace_back( mn ), ans.emplace_back( mx );
    } 
    sort( ans.begin(), ans.end() );
    for( int i = 0 ; i < ( int )ans.size() - 1 ; i++ ) ret = max( ret, ans[i+1] - ans[i] );
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 428 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 14 ms 868 KB Output is correct
17 Correct 14 ms 896 KB Output is correct
18 Correct 18 ms 896 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Correct 12 ms 896 KB Output is correct
21 Correct 62 ms 2300 KB Output is correct
22 Correct 59 ms 2288 KB Output is correct
23 Correct 57 ms 2288 KB Output is correct
24 Correct 69 ms 2288 KB Output is correct
25 Correct 49 ms 2288 KB Output is correct
26 Correct 58 ms 2288 KB Output is correct
27 Correct 55 ms 2288 KB Output is correct
28 Correct 56 ms 2308 KB Output is correct
29 Correct 56 ms 2388 KB Output is correct
30 Correct 45 ms 2436 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 17 ms 896 KB Output is correct
17 Correct 19 ms 896 KB Output is correct
18 Correct 20 ms 896 KB Output is correct
19 Correct 17 ms 896 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 66 ms 2288 KB Output is correct
22 Correct 69 ms 2292 KB Output is correct
23 Correct 68 ms 2288 KB Output is correct
24 Correct 68 ms 2288 KB Output is correct
25 Correct 63 ms 3308 KB Output is correct
26 Correct 78 ms 2288 KB Output is correct
27 Correct 67 ms 2288 KB Output is correct
28 Correct 78 ms 2288 KB Output is correct
29 Correct 71 ms 2288 KB Output is correct
30 Correct 36 ms 1408 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct