Submission #764402

# Submission time Handle Problem Language Result Execution time Memory
764402 2023-06-23T11:23:51 Z Ahmed57 Gap (APIO16_gap) C++17
100 / 100
38 ms 1112 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
long long findGap(int T,int N){
    long long mn ,mx;
    MinMax(0,INF,&mn,&mx);
    if(N==2)return (mx-mn);
    if(T==1){
        long long all= 0;
        for(int i = 0;i<(N-1)/2;i++){
            long long mn2 , mx2;
            MinMax(mn+1,mx-1,&mn2,&mx2);
            all = max(all,mn2-mn);
            all = max(all,mx-mx2);
            swap(mn,mn2);swap(mx,mx2);
        }
        all = max(all,mx-mn);
        return all;
    }
    long long diff = (mx-mn+(N-1))/N;
    long long ans = diff;
    long long start = mn;
    long long la = mn;
    while(start<mx){
        long long l = start+1 , r = start+ans+1;
        long long mn2 , mx2 ;
        MinMax(l,r,&mn2,&mx2);
        if(mn2!=-1){
            ans = max(ans,mn2-la);
            la = mx2;
            start = mx2;
        }else{
            start+=ans;
        }
    }
    return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 7 ms 464 KB Output is correct
17 Correct 7 ms 464 KB Output is correct
18 Correct 7 ms 504 KB Output is correct
19 Correct 7 ms 508 KB Output is correct
20 Correct 6 ms 464 KB Output is correct
21 Correct 30 ms 1060 KB Output is correct
22 Correct 27 ms 1096 KB Output is correct
23 Correct 27 ms 1112 KB Output is correct
24 Correct 29 ms 1060 KB Output is correct
25 Correct 25 ms 1072 KB Output is correct
26 Correct 29 ms 1064 KB Output is correct
27 Correct 30 ms 1064 KB Output is correct
28 Correct 29 ms 1084 KB Output is correct
29 Correct 29 ms 976 KB Output is correct
30 Correct 33 ms 1068 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 5 ms 464 KB Output is correct
17 Correct 5 ms 516 KB Output is correct
18 Correct 5 ms 464 KB Output is correct
19 Correct 5 ms 464 KB Output is correct
20 Correct 3 ms 520 KB Output is correct
21 Correct 18 ms 1060 KB Output is correct
22 Correct 24 ms 956 KB Output is correct
23 Correct 23 ms 964 KB Output is correct
24 Correct 24 ms 984 KB Output is correct
25 Correct 38 ms 976 KB Output is correct
26 Correct 17 ms 1048 KB Output is correct
27 Correct 24 ms 1056 KB Output is correct
28 Correct 21 ms 1028 KB Output is correct
29 Correct 21 ms 1048 KB Output is correct
30 Correct 16 ms 988 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct