답안 #145634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145634 2019-08-20T14:19:07 Z karma Gap (APIO16_gap) C++11
100 / 100
77 ms 4460 KB
#include<bits/stdc++.h>
#include "gap.h"
#define ll   long long

using namespace std;

const ll oo = (ll)1e18;

ll findGap(int T, int N)
{
   ll Min, Max, preMin, preMax, res = 0;
   MinMax(0, oo, &Min, &Max);
   vector<ll> v; v.clear();
   if(T == 1) {
     int i = 1, j = N - 2;
     v.emplace_back(Min), v.emplace_back(Max);
     while(i <= j) {
         preMin = Min, preMax = Max;
         MinMax(preMin + 1, preMax - 1, &Min, &Max);
         if(Min != -1) v.emplace_back(Min), v.emplace_back(Max);
         ++i, --j;
     }
   } else {
     preMin = Min, preMax = Max;
     res = (Max - Min + N - 2) / (N - 1); ll dis = res + 1;
     v.emplace_back(Min), v.emplace_back(Max);
     for(ll pos = preMin + 1; pos < preMax; pos += dis) {
        MinMax(pos, pos + res, &Min, &Max);
        if(Min != -1) v.emplace_back(Min), v.emplace_back(Max);
     }
   }
   sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
   for(int i = 1; i < int(v.size()); ++i) res = max(res, v[i] - v[i - 1]);
   return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 248 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 17 ms 1400 KB Output is correct
17 Correct 16 ms 1400 KB Output is correct
18 Correct 16 ms 1400 KB Output is correct
19 Correct 16 ms 1400 KB Output is correct
20 Correct 12 ms 1016 KB Output is correct
21 Correct 61 ms 4212 KB Output is correct
22 Correct 60 ms 4208 KB Output is correct
23 Correct 60 ms 4128 KB Output is correct
24 Correct 61 ms 4080 KB Output is correct
25 Correct 52 ms 3516 KB Output is correct
26 Correct 60 ms 4080 KB Output is correct
27 Correct 60 ms 4080 KB Output is correct
28 Correct 60 ms 4080 KB Output is correct
29 Correct 61 ms 4208 KB Output is correct
30 Correct 45 ms 2928 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 20 ms 1528 KB Output is correct
17 Correct 20 ms 1400 KB Output is correct
18 Correct 20 ms 1400 KB Output is correct
19 Correct 21 ms 1400 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 77 ms 4168 KB Output is correct
22 Correct 76 ms 4088 KB Output is correct
23 Correct 76 ms 4080 KB Output is correct
24 Correct 76 ms 4080 KB Output is correct
25 Correct 73 ms 4460 KB Output is correct
26 Correct 77 ms 4080 KB Output is correct
27 Correct 76 ms 4208 KB Output is correct
28 Correct 76 ms 4208 KB Output is correct
29 Correct 76 ms 4096 KB Output is correct
30 Correct 37 ms 2172 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct