답안 #338717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338717 2020-12-23T18:39:57 Z bigDuck Gap (APIO16_gap) C++14
100 / 100
72 ms 1292 KB
#include "gap.h"

#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll


int n;
int l1, r1;
int subtask_1(){

int l=-2, r=(1e18); r+=1;
int mx=1;
int cnt=0;
while(cnt<n){

    MinMax(l+1, r-1, &l1, &r1);
    if( (cnt>0)  ){
        mx=max(max((ll)l1-l, (ll)r-r1), mx);
    }
    cnt+=2;
    l=l1, r=r1;
    //cout<<l<<" "<<r<<"\n"<<flush;
}
mx=max(mx, r-l);
return mx;
}





int subtask_2(){


int ft, lt;
MinMax(0, 1e18, &ft, &lt);

int d=((lt-ft+1)/n)+( (((lt-ft+1)%n)>0)?(1):(0)  );
int res=0;
int l=-1, r=ft;
int l1=-1, r1=-1;
for(int i=ft+1; i<lt; i+=d){
    MinMax(i, min(i+d-1, lt-1), &l1, &r1);
    res=max(res, l1-r);
    r=max(r1, r);
}
res=max(res, lt-r);
return res;

}








long long findGap(int32_t T, int32_t N)
{
    n=N;
    if(T==1){
        return subtask_1();
    }
    else{
        return subtask_2();
    }
}

Compilation message

gap.cpp: In function 'long long int subtask_2()':
gap.cpp:49:5: warning: unused variable 'l' [-Wunused-variable]
   49 | int l=-1, r=ft;
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 380 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 12 ms 512 KB Output is correct
17 Correct 11 ms 620 KB Output is correct
18 Correct 11 ms 492 KB Output is correct
19 Correct 11 ms 492 KB Output is correct
20 Correct 9 ms 512 KB Output is correct
21 Correct 47 ms 1132 KB Output is correct
22 Correct 44 ms 1132 KB Output is correct
23 Correct 42 ms 1132 KB Output is correct
24 Correct 42 ms 1244 KB Output is correct
25 Correct 37 ms 1260 KB Output is correct
26 Correct 42 ms 1152 KB Output is correct
27 Correct 43 ms 1132 KB Output is correct
28 Correct 42 ms 1148 KB Output is correct
29 Correct 49 ms 1144 KB Output is correct
30 Correct 39 ms 1132 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 508 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 14 ms 492 KB Output is correct
17 Correct 15 ms 492 KB Output is correct
18 Correct 14 ms 492 KB Output is correct
19 Correct 14 ms 492 KB Output is correct
20 Correct 9 ms 636 KB Output is correct
21 Correct 72 ms 1132 KB Output is correct
22 Correct 59 ms 1132 KB Output is correct
23 Correct 64 ms 1132 KB Output is correct
24 Correct 61 ms 1132 KB Output is correct
25 Correct 66 ms 1260 KB Output is correct
26 Correct 60 ms 1260 KB Output is correct
27 Correct 59 ms 1132 KB Output is correct
28 Correct 63 ms 1292 KB Output is correct
29 Correct 60 ms 1132 KB Output is correct
30 Correct 34 ms 1132 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct