제출 #560844

#제출 시각아이디문제언어결과실행 시간메모리
560844tamthegodGap (APIO16_gap)C++14
0 / 100
69 ms1164 KiB
#include "gap.h"

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<cstdio>
#include<bitset>
#include<chrono>
#include<random>
#include<ext/rope>
/* ordered_set
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
ll a[maxN];
ll findGap(int T, int n)
{
    ll res = 0;
    MinMax(0, oo, &a[1], &a[n]);
    if(n == 2) return a[n] - a[1];
    ll pre = a[1];
    ll h = (a[n] - a[1] + n - 1) / (n - 1);
    ll now = a[1];
    while(true)
    {
        ll p, q;
        MinMax(now, now + h, &p, &q);
        res = max(res, q - pre);
        pre = max(pre, q);
        now += h + 1;
        if(q == a[n]) break;
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...