제출 #23318

#제출 시각아이디문제언어결과실행 시간메모리
23318duongthoi1999Gap (APIO16_gap)C++14
0 / 100
36 ms7496 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<ll, int> ii;
const int mod = (int) 1e9 + 7;
const ll inf = 1LL << 60;
const int maxn = (int) 1e5 + 5;
const ld eps = 1e-9;

vector<ll> a, b;
int l[maxn], r[maxn];

ll findGap(int T, int N) {
	a.resize(N + 1, 0);
	b.resize(N + 1, 0);
	MinMax(0, inf, &a[0], &a[N]);
	b[0] = a[0]; b[N] = a[N];
	ll len = a[N] - a[0] - 1;
    int g = min(len, 1LL * N - 1);
    int sg = len % g;
    int bg = g - sg;
    l[0] = r[0] = a[0];
    a[g + 1] = a[N];
    b[g + 1] = b[N];
    rep(i, 1, g + 1) {
        l[i] = r[i - 1] + 1;
        if(i <= sg) r[i] = l[i] + (len / g) - 1;
        else r[i] = l[i] + (len / g);
        MinMax(l[i], r[i], &a[i], &b[i]);
    }
    ll res = 1;
    int j = 0;
    rep(i, 0, g + 2) {
        res = max(res, a[i] - b[j]);
        if(a[i] == -1 && b[i] == -1) continue;
        j = i;
    }
	return res;
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:30:9: warning: unused variable 'bg' [-Wunused-variable]
     int bg = g - sg;
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...