답안 #96005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96005 2019-02-05T06:09:16 Z oolimry Gap (APIO16_gap) C++14
100 / 100
99 ms 4460 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int T, int N)
{
    if(T == 1){
        long long arr[N];
        int x = 0;
        long long a, b;
        a = 0;
        b = 1000000000000000005;
        long long mn, mx;
        while(true){
            MinMax(a,b,&mn,&mx);
            arr[x] = mn;
            arr[N-x-1] = mx;
            a = mn + 1;
            b = mx - 1;
            x++;
            if ((x >= (N+1)/2)) break;
        }
        long long mm = 0;
        for(int i = 0;i < N-1;i++){
            mm = std::max(mm,arr[i+1]-arr[i]);
        }
        return mm;
    }
    else{
        long long a, b;
        a = 0;
        b = 1000000000000000005;
        long long mn, mx;
        MinMax(a,b,&mn,&mx);
        std::vector<long long> v;
        v.push_back(mn);
        v.push_back(mx);
        long long dist = mx - mn - 2;
        long long small = dist / (N-1);
        long long big = small+1;
        a = mn + 1;
        for(int i = 0;i < N-1;i++){
            if(i < dist % (N-1)) b = a + big;
            else b = a + small;
            MinMax(a,b-1,&mn,&mx);
            //printf("%lld %lld\n",a,b-1);
            if(mn != -1){
                v.push_back(mn);
                v.push_back(mx);
            }
            a = b;
        }
        long long mm = 0;
        sort(v.begin(),v.end());
        for(int i = 0;i < v.size()-1;i++){
            mm = std::max(mm,v[i+1]-v[i]);
        }
        return mm;
    }
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:54:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0;i < v.size()-1;i++){
                       ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 13 ms 1016 KB Output is correct
17 Correct 12 ms 1016 KB Output is correct
18 Correct 12 ms 1144 KB Output is correct
19 Correct 28 ms 1148 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 46 ms 3704 KB Output is correct
22 Correct 46 ms 3576 KB Output is correct
23 Correct 46 ms 3640 KB Output is correct
24 Correct 46 ms 3704 KB Output is correct
25 Correct 38 ms 2936 KB Output is correct
26 Correct 99 ms 3576 KB Output is correct
27 Correct 47 ms 3592 KB Output is correct
28 Correct 46 ms 3704 KB Output is correct
29 Correct 46 ms 3700 KB Output is correct
30 Correct 33 ms 2424 KB Output is correct
31 Correct 2 ms 252 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 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 380 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 2 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 2 ms 376 KB Output is correct
16 Correct 17 ms 1244 KB Output is correct
17 Correct 26 ms 1272 KB Output is correct
18 Correct 17 ms 1244 KB Output is correct
19 Correct 40 ms 1244 KB Output is correct
20 Correct 9 ms 632 KB Output is correct
21 Correct 65 ms 4080 KB Output is correct
22 Correct 64 ms 4080 KB Output is correct
23 Correct 64 ms 4080 KB Output is correct
24 Correct 64 ms 4080 KB Output is correct
25 Correct 62 ms 4460 KB Output is correct
26 Correct 65 ms 4080 KB Output is correct
27 Correct 63 ms 4080 KB Output is correct
28 Correct 63 ms 4016 KB Output is correct
29 Correct 63 ms 4080 KB Output is correct
30 Correct 32 ms 2168 KB Output is correct
31 Correct 2 ms 252 KB Output is correct
32 Correct 2 ms 376 KB Output is correct