답안 #47963

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47963 2018-05-09T08:42:13 Z 3zp Gap (APIO16_gap) C++14
70 / 100
72 ms 2640 KB
#include "gap.h"
#define ll long long
#include<bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
    if(T == 1){
        ll s=-1, t=1e18+1;
        vector<ll> v;
        for(int i= 0; i < (N+1)/2; i++){
            MinMax(s+1, t-1, &s, &t);
            if(s == -1) break;
            else v.push_back(s),v.push_back(t);
        }
        sort(v.begin(),v.end());
        ll ans = 0;
        for(int i= 1; i < v.size(); i++)
            ans=max(ans, v[i]-v[i-1]);
        return ans;
    }
    ll s, t;
    MinMax(0, 1e18, &s, &t);
    ll L = t - s;
    ll d = (L+N-2) / (N - 1);
    ll ans = d;
    d++;
    ll x = s;
    while(x != t){
        ll p, q;
        if(x + d >= t) break;
         MinMax(x + 1, x + d, &p , &q);
        if(q != -1) {
            ans = max(ans, x - p);
            x = q;
            continue;
        }
        int w = 2;
        while(1){

            MinMax(x + 1,min( x + w * d, (ll)1e18),&p , &q);
            if(q == -1) {w++; continue;}
            ans = max(ans, p - x);
            d = ans;
            x = q;
            break;
        }
    }
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:17:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i= 1; i < v.size(); i++)
                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 412 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 3 ms 592 KB Output is correct
12 Correct 2 ms 624 KB Output is correct
13 Correct 2 ms 624 KB Output is correct
14 Correct 3 ms 624 KB Output is correct
15 Correct 2 ms 624 KB Output is correct
16 Correct 17 ms 1148 KB Output is correct
17 Correct 17 ms 1148 KB Output is correct
18 Correct 24 ms 1148 KB Output is correct
19 Correct 16 ms 1148 KB Output is correct
20 Correct 12 ms 1152 KB Output is correct
21 Correct 70 ms 2548 KB Output is correct
22 Correct 60 ms 2608 KB Output is correct
23 Correct 60 ms 2608 KB Output is correct
24 Correct 63 ms 2608 KB Output is correct
25 Correct 53 ms 2608 KB Output is correct
26 Correct 72 ms 2608 KB Output is correct
27 Correct 61 ms 2640 KB Output is correct
28 Correct 63 ms 2640 KB Output is correct
29 Correct 60 ms 2640 KB Output is correct
30 Correct 47 ms 2640 KB Output is correct
31 Incorrect 2 ms 2640 KB Output isn't correct
32 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2640 KB Output is correct
3 Correct 2 ms 2640 KB Output is correct
4 Correct 2 ms 2640 KB Output is correct
5 Correct 2 ms 2640 KB Output is correct
6 Correct 2 ms 2640 KB Output is correct
7 Correct 2 ms 2640 KB Output is correct
8 Correct 2 ms 2640 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 2 ms 2640 KB Output is correct
11 Correct 2 ms 2640 KB Output is correct
12 Correct 3 ms 2640 KB Output is correct
13 Correct 3 ms 2640 KB Output is correct
14 Correct 2 ms 2640 KB Output is correct
15 Correct 2 ms 2640 KB Output is correct
16 Correct 11 ms 2640 KB Output is correct
17 Correct 10 ms 2640 KB Output is correct
18 Correct 10 ms 2640 KB Output is correct
19 Correct 11 ms 2640 KB Output is correct
20 Correct 8 ms 2640 KB Output is correct
21 Correct 35 ms 2640 KB Output is correct
22 Correct 36 ms 2640 KB Output is correct
23 Correct 36 ms 2640 KB Output is correct
24 Correct 38 ms 2640 KB Output is correct
25 Correct 67 ms 2640 KB Output is correct
26 Correct 39 ms 2640 KB Output is correct
27 Correct 44 ms 2640 KB Output is correct
28 Correct 37 ms 2640 KB Output is correct
29 Correct 38 ms 2640 KB Output is correct
30 Correct 26 ms 2640 KB Output is correct
31 Correct 2 ms 2640 KB Output is correct
32 Correct 2 ms 2640 KB Output is correct