Submission #92002

# Submission time Handle Problem Language Result Execution time Memory
92002 2018-12-31T23:54:49 Z updown1 Gap (APIO16_gap) C++17
30 / 100
98 ms 6136 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);
    For (i, 0, N-1) {
        MinMax(l+(i*(r-l))/(N-1)+1, l+((i+1)*(r-l))/(N-1), &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;
}
# Verdict Execution time Memory 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 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 12 ms 1016 KB Output is correct
17 Correct 12 ms 1144 KB Output is correct
18 Correct 13 ms 1016 KB Output is correct
19 Correct 12 ms 1016 KB Output is correct
20 Correct 9 ms 888 KB Output is correct
21 Correct 46 ms 2164 KB Output is correct
22 Correct 45 ms 2168 KB Output is correct
23 Correct 45 ms 2140 KB Output is correct
24 Correct 46 ms 2296 KB Output is correct
25 Correct 38 ms 2168 KB Output is correct
26 Correct 46 ms 2168 KB Output is correct
27 Correct 46 ms 2140 KB Output is correct
28 Correct 45 ms 2168 KB Output is correct
29 Correct 45 ms 2168 KB Output is correct
30 Correct 33 ms 2168 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 252 KB Output is correct
2 Runtime error 1 ms 376 KB Execution failed because the return code was nonzero
3 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
4 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
5 Correct 2 ms 376 KB Output is correct
6 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
7 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
8 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
9 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
10 Correct 2 ms 252 KB Output is correct
11 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
12 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
13 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
14 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
15 Correct 3 ms 376 KB Output is correct
16 Runtime error 8 ms 1016 KB Execution failed because the return code was nonzero
17 Runtime error 7 ms 1016 KB Execution failed because the return code was nonzero
18 Runtime error 7 ms 1016 KB Execution failed because the return code was nonzero
19 Runtime error 8 ms 1016 KB Execution failed because the return code was nonzero
20 Correct 9 ms 760 KB Output is correct
21 Runtime error 24 ms 1656 KB Execution failed because the return code was nonzero
22 Runtime error 24 ms 1656 KB Execution failed because the return code was nonzero
23 Runtime error 24 ms 1528 KB Execution failed because the return code was nonzero
24 Runtime error 24 ms 1528 KB Execution failed because the return code was nonzero
25 Correct 98 ms 6136 KB Output is correct
26 Runtime error 24 ms 1656 KB Execution failed because the return code was nonzero
27 Runtime error 25 ms 1656 KB Execution failed because the return code was nonzero
28 Runtime error 25 ms 1656 KB Execution failed because the return code was nonzero
29 Runtime error 24 ms 1656 KB Execution failed because the return code was nonzero
30 Correct 40 ms 2296 KB Output is correct
31 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
32 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero