답안 #125943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125943 2019-07-06T14:51:17 Z kjp4155 Gap (APIO16_gap) C++17
100 / 100
76 ms 3304 KB
#include "gap.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
ll MX = 1e18;
ll A[500500];
 
ll findGap1(int N){
    int L=1, R=N;
    ll mn = 0, mx = MX;
    while( L <= R ){
        ll a,b;
        MinMax(mn, mx, &a, &b);
        A[L++] = a; A[R--] = b;
        mn = a + 1; mx = b-1;
    }
 
    ll ans = 0;
    for(int i=1;i<N;i++) ans = max(ans, A[i+1]-A[i]);
 
    return ans;
}
 
ll findGap2(int N){
    ll L = 0, R = 1e18;
    MinMax(L, R, &L, &R);

    if( N == 2 ){
        return R-L;
    }

    ll gap = (R-L+(N-1))/(N-2);
    ll ans = 0;

    vector<ll> v;
    v.push_back(L);
    for(ll i=L;i<R;i+=gap+1){
        ll l,r; MinMax(i, i+gap, &l, &r);
        if( l != -1 ) v.push_back(l);
        if( r != -1 ) v.push_back(r);
    }

    v.push_back(R);
    for(int i=0;i<v.size()-1;i++) ans = max(ans, v[i+1]-v[i]);

    return ans;
}
 
long long findGap(int T, int N){
    if( T == 1 ) return findGap1(N);
    else return findGap2(N);
}

Compilation message

gap.cpp: In function 'll findGap2(int)':
gap.cpp:46:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v.size()-1;i++) ans = max(ans, v[i+1]-v[i]);
                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 15 ms 760 KB Output is correct
17 Correct 15 ms 760 KB Output is correct
18 Correct 15 ms 760 KB Output is correct
19 Correct 15 ms 760 KB Output is correct
20 Correct 11 ms 760 KB Output is correct
21 Correct 55 ms 1912 KB Output is correct
22 Correct 55 ms 1912 KB Output is correct
23 Correct 55 ms 1912 KB Output is correct
24 Correct 55 ms 1912 KB Output is correct
25 Correct 46 ms 1912 KB Output is correct
26 Correct 55 ms 1872 KB Output is correct
27 Correct 55 ms 1912 KB Output is correct
28 Correct 57 ms 1916 KB Output is correct
29 Correct 54 ms 1912 KB Output is correct
30 Correct 40 ms 1912 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 19 ms 888 KB Output is correct
17 Correct 20 ms 888 KB Output is correct
18 Correct 20 ms 940 KB Output is correct
19 Correct 20 ms 888 KB Output is correct
20 Correct 10 ms 604 KB Output is correct
21 Correct 74 ms 2288 KB Output is correct
22 Correct 74 ms 2288 KB Output is correct
23 Correct 73 ms 2288 KB Output is correct
24 Correct 74 ms 2160 KB Output is correct
25 Correct 71 ms 3304 KB Output is correct
26 Correct 76 ms 2364 KB Output is correct
27 Correct 75 ms 2288 KB Output is correct
28 Correct 76 ms 2288 KB Output is correct
29 Correct 75 ms 2288 KB Output is correct
30 Correct 38 ms 1528 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct