답안 #750902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750902 2023-05-30T13:09:08 Z M_W Gap (APIO16_gap) C++17
100 / 100
81 ms 5776 KB
#include <bits/stdc++.h>
// #include "grader.cpp"
#include "gap.h"
using namespace std;

long long findGap(int T, int N){
  set<long long> s;
  long long L, R;
  if(T == 1){
    MinMax(1, 1e18, &L, &R);
    s.insert(L); s.insert(R);
    for(int i = 1; i < (N + 1) >> 1; i++){
      long long qs, qt;
      MinMax(L + 1, R - 1, &qs, &qt);
      s.insert(qs); s.insert(qt);
      L = qs; R = qt;
    }
  }
  else{
    MinMax(1, 1e18, &L, &R);

    long long X = (R - L) / ((N * 1ll) - 1);
    X += (R - L) % ((N * 1ll) - 1) != 0;

    long long qs, qt;
    for(long long i = L + 1; i < R; i += X){
      MinMax(i, i + X - 1, &qs, &qt);
      s.insert(qs); s.insert(qt);
    }
    s.erase(-1ll);
  }

  long long ans = 0, old = L;
  for(auto x : s){
    ans = max(ans, x - old);
    old = x;
  }
  return ans;
}
# 결과 실행 시간 메모리 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 1 ms 336 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 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 13 ms 1632 KB Output is correct
17 Correct 12 ms 1568 KB Output is correct
18 Correct 13 ms 1648 KB Output is correct
19 Correct 13 ms 1640 KB Output is correct
20 Correct 10 ms 1588 KB Output is correct
21 Correct 53 ms 5668 KB Output is correct
22 Correct 52 ms 5704 KB Output is correct
23 Correct 57 ms 5664 KB Output is correct
24 Correct 57 ms 5772 KB Output is correct
25 Correct 51 ms 5704 KB Output is correct
26 Correct 53 ms 5668 KB Output is correct
27 Correct 57 ms 5744 KB Output is correct
28 Correct 54 ms 5712 KB Output is correct
29 Correct 53 ms 5708 KB Output is correct
30 Correct 51 ms 5776 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 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 17 ms 1512 KB Output is correct
17 Correct 18 ms 1556 KB Output is correct
18 Correct 17 ms 1488 KB Output is correct
19 Correct 17 ms 1488 KB Output is correct
20 Correct 7 ms 464 KB Output is correct
21 Correct 76 ms 5284 KB Output is correct
22 Correct 75 ms 5276 KB Output is correct
23 Correct 77 ms 5288 KB Output is correct
24 Correct 76 ms 5280 KB Output is correct
25 Correct 81 ms 5752 KB Output is correct
26 Correct 78 ms 5280 KB Output is correct
27 Correct 74 ms 5356 KB Output is correct
28 Correct 75 ms 5180 KB Output is correct
29 Correct 73 ms 5156 KB Output is correct
30 Correct 32 ms 1836 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct