답안 #92006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92006 2019-01-01T00:11:40 Z updown1 Gap (APIO16_gap) C++17
100 / 100
96 ms 5880 KB
/*
https://codeforces.com/blog/entry/44657?#comment-293060
*/
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 2, N)
#define ffj For(j, 0, N)
#define ffa ffi ffj
#define ss <<" "<<
#define c <<" : "<<
#define w cout
#define e endl//"\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
//#define int ll
const int MAXN=100000;
///500,000,000
long long findGap(int T, int N) {
    if (T == 1) {
        ll ans[N], l = 0, r = N-1, mn, mx;
        while (r >= l) {
            if (l == 0) MinMax(0, 1e18, &mn, &mx);
            else if (ans[l-1]+1 <= ans[r+1]-1) MinMax(ans[l-1]+1, ans[r+1]-1, &mn, &mx);
            ans[l] = mn; ans[r] = mx;
            l++; r--;
        }
        ll ret = 0;
        For (i, 1, N) ret = max(ret, ans[i] - ans[i-1]);
        return ret;
    }
    ll l, r, mn, mx;
    MinMax(0, 1e18, &l, &r);
    set<ll> vals; vals.insert(l); vals.insert(r);
    ll ad = (r-l+N-2)/(N-1);
    For (i, 0, N-1) if (min(r-1, l+(i+1)*ad) >= l+i*ad+1) {
        MinMax(l+i*ad+1, min(r-1, l+(i+1)*ad), &mn, &mx); vals.insert(mn); vals.insert(mx);
    }
    ll prev = l;
    ll ret = 0;
    for (ll i: vals) {
        if (i == -1) continue;
        ret = max(ret, i-prev);
        prev = i;
    }
	return ret;
}
# 결과 실행 시간 메모리 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 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 12 ms 760 KB Output is correct
17 Correct 12 ms 760 KB Output is correct
18 Correct 13 ms 760 KB Output is correct
19 Correct 12 ms 760 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 46 ms 1912 KB Output is correct
22 Correct 46 ms 1896 KB Output is correct
23 Correct 46 ms 1912 KB Output is correct
24 Correct 47 ms 1912 KB Output is correct
25 Correct 39 ms 1912 KB Output is correct
26 Correct 46 ms 1884 KB Output is correct
27 Correct 46 ms 1872 KB Output is correct
28 Correct 46 ms 1884 KB Output is correct
29 Correct 46 ms 1912 KB Output is correct
30 Correct 34 ms 1912 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 380 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 21 ms 1528 KB Output is correct
17 Correct 22 ms 1656 KB Output is correct
18 Correct 22 ms 1656 KB Output is correct
19 Correct 22 ms 1656 KB Output is correct
20 Correct 9 ms 632 KB Output is correct
21 Correct 93 ms 5368 KB Output is correct
22 Correct 90 ms 5364 KB Output is correct
23 Correct 91 ms 5368 KB Output is correct
24 Correct 91 ms 5368 KB Output is correct
25 Correct 92 ms 5880 KB Output is correct
26 Correct 95 ms 5320 KB Output is correct
27 Correct 92 ms 5240 KB Output is correct
28 Correct 92 ms 5340 KB Output is correct
29 Correct 96 ms 5240 KB Output is correct
30 Correct 37 ms 1912 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct