Submission #252689

# Submission time Handle Problem Language Result Execution time Memory
252689 2020-07-26T06:32:45 Z ChrisT Gap (APIO16_gap) C++17
100 / 100
74 ms 1916 KB
#include<bits/stdc++.h>
using namespace std;
#include "gap.h"
long long findGap (int t, int n) {
  if (t == 1) {
    vector<long long> arr(n+1);
    long long low = -1, high = 1'000'000'000LL * 1'000'000'000LL + 1;
    for (int i = 1; i <= (n+1)/2; i++) {
      MinMax(low+1,high-1,&low,&high);
      arr[i] = low; arr[n-i+1] = high;
    }
    long long mx = 0;
    for (int i = 1; i < n; i++) {
      mx = max(mx,arr[i+1] - arr[i]);
    }
    return mx;
  } else {
    long long mx,mn;
    MinMax(0,1e18,&mn,&mx); 
    long long go = max(1LL,(mx - mn + n - 2) / (n - 1)), ret = 0, lstmx = mn;
    for (long long cur = mn+1; cur < mx; cur += go) {
      long long ed = min(cur + go-1,mx-1);
      long long low,high;
      MinMax(cur,ed,&low,&high);
      if (low != -1) {
        ret = max(ret,low - lstmx);
        lstmx = high;
      }
    }
    ret = max(ret,mx - lstmx);
    return ret;
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 12 ms 768 KB Output is correct
17 Correct 12 ms 768 KB Output is correct
18 Correct 12 ms 768 KB Output is correct
19 Correct 12 ms 768 KB Output is correct
20 Correct 9 ms 768 KB Output is correct
21 Correct 53 ms 1912 KB Output is correct
22 Correct 50 ms 1912 KB Output is correct
23 Correct 51 ms 1912 KB Output is correct
24 Correct 48 ms 1892 KB Output is correct
25 Correct 43 ms 1912 KB Output is correct
26 Correct 50 ms 1912 KB Output is correct
27 Correct 58 ms 1912 KB Output is correct
28 Correct 50 ms 1916 KB Output is correct
29 Correct 51 ms 1860 KB Output is correct
30 Correct 41 ms 1912 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 512 KB Output is correct
17 Correct 18 ms 512 KB Output is correct
18 Correct 16 ms 512 KB Output is correct
19 Correct 18 ms 512 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 67 ms 1144 KB Output is correct
22 Correct 66 ms 1148 KB Output is correct
23 Correct 66 ms 1272 KB Output is correct
24 Correct 66 ms 1148 KB Output is correct
25 Correct 59 ms 1108 KB Output is correct
26 Correct 74 ms 1148 KB Output is correct
27 Correct 64 ms 1060 KB Output is correct
28 Correct 74 ms 1148 KB Output is correct
29 Correct 65 ms 1144 KB Output is correct
30 Correct 34 ms 1152 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct