답안 #407437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
407437 2021-05-19T00:34:35 Z Blobo2_Blobo2 Gap (APIO16_gap) C++14
100 / 100
59 ms 1880 KB
#include "gap.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;

long long findGap(int T, int N){
    long long arr[N];
    if(T==1){
        long long idx=0,mx,mn,l=0,r=1e18;
        for(int i=0;i<N/2+(N%2);i++){
            MinMax(l,r,&mn,&mx);
            arr[i]=mn;
            arr[N-i-1]=mx;
            l=mn+1;
            r=mx-1;
        }
    }
    else{
        long long idx=0,mx,mn,l=0,r=1e18;
        MinMax(l,r,&mn,&mx);
        l=mn;
        r=mx;
        long long extra=(r-l+N-2)/(N-1);
        for(long long i=l+1;i<r;){
            MinMax(i,i+extra-1,&mn,&mx);
            if(mx!=-1){
                i=mx+1;
                continue;
            }
            for(long long  j=2;;j++){
                MinMax(i,i+j*extra-1,&mn,&mx);
                if(mn!=-1){
                    extra=mn-i+1,i=mx+1;
                    break;
                }
            }
        }
        return extra;
    }
    long long ans=0;
    for(int i=0;i<N-1;i++)
        ans=max(ans,arr[i+1]-arr[i]);
    return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:19: warning: unused variable 'idx' [-Wunused-variable]
    9 |         long long idx=0,mx,mn,l=0,r=1e18;
      |                   ^~~
gap.cpp:19:19: warning: unused variable 'idx' [-Wunused-variable]
   19 |         long long idx=0,mx,mn,l=0,r=1e18;
      |                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 12 ms 584 KB Output is correct
17 Correct 11 ms 584 KB Output is correct
18 Correct 11 ms 584 KB Output is correct
19 Correct 11 ms 600 KB Output is correct
20 Correct 9 ms 584 KB Output is correct
21 Correct 45 ms 1856 KB Output is correct
22 Correct 46 ms 1728 KB Output is correct
23 Correct 43 ms 1824 KB Output is correct
24 Correct 44 ms 1788 KB Output is correct
25 Correct 39 ms 1880 KB Output is correct
26 Correct 44 ms 1820 KB Output is correct
27 Correct 47 ms 1832 KB Output is correct
28 Correct 44 ms 1816 KB Output is correct
29 Correct 44 ms 1816 KB Output is correct
30 Correct 37 ms 1856 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Correct 1 ms 200 KB Output is correct
6 Correct 1 ms 200 KB Output is correct
7 Correct 1 ms 200 KB Output is correct
8 Correct 1 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 10 ms 584 KB Output is correct
17 Correct 8 ms 584 KB Output is correct
18 Correct 8 ms 624 KB Output is correct
19 Correct 8 ms 584 KB Output is correct
20 Correct 6 ms 672 KB Output is correct
21 Correct 29 ms 1780 KB Output is correct
22 Correct 30 ms 1728 KB Output is correct
23 Correct 30 ms 1816 KB Output is correct
24 Correct 30 ms 1816 KB Output is correct
25 Correct 59 ms 1860 KB Output is correct
26 Correct 30 ms 1744 KB Output is correct
27 Correct 30 ms 1876 KB Output is correct
28 Correct 30 ms 1820 KB Output is correct
29 Correct 28 ms 1836 KB Output is correct
30 Correct 24 ms 1864 KB Output is correct
31 Correct 1 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct