# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154770 | Mercenary | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 6;
ll a[maxn];
long long findGap(int T, int N)
{
int n = N;
if(T == 1){
ll u = 0 - 1 , v = 1e18 + 1;
for(int i = 1 , j = n ; i + 1 < j ; ++i , --j){
MinMax(u + 1 , v - 1 , a[i] , a[j]);
u = a[i] , v = a[j];
}
ll res = 0;
for(int i = 2 ; i <= n ; ++i){
res = max(res , a[i] - a[i - 1]);
}
return res;
}
else{
ll u = 0 , v = 1e18;
MinMax(u , v , u , v);
ll gap = (v - u) / (n - 1);
a[1] = u;
ll res = 0;
for(int i = 2 ; i <= n ; ++i){
MinMax(a[i - 1] , a[i - 1] + gap , a[i - 1] , a[i]);
if(a[i] == -1)a[i] = a[i - 1] + 1;
}
a[n] = v;
for(int i = 2 ; i <= n ; ++i)res = max(res , a[i] - a[i - 1]);
return res;
}
}