# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
109319 |
2019-05-06T06:55:48 Z |
b2563125 |
Gap (APIO16_gap) |
C++14 |
|
0 ms |
0 KB |
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define vel vector<long long>
#define ll long long
#define rep(i,n) for(long long i=0;i<n;i++)
int pr = 1000000007;
vel a;
int co = 0;
int ref(int &a) {
a = a % pr;
a += pr;
a = a % pr;
return a;
}
void MinMax(ll s, ll t, ll &mn, ll &mx) {
if (s > t) { cout << "ERROR"; return; }
auto mn1 = lower_bound(a.begin(), a.end(), s);
auto mx1 = upper_bound(a.begin(), a.end(), t);
if (mx1 == a.begin()) { mn = -1; mx = -1; return; }
mx1--;
if (mn1 != a.end()) {
mn = *mn1; mx = *mx1;
if (mn > mx) { mn = -1; mx = -1; return; }
}
else {
mn = -1;
mx = -1;
}
}
long long findGap(int t, int n) {
long long N = n;
long long a1; long long an;
long long INF = pr - 7;
INF *= INF;
MinMax(0, INF, a1, an);
long long X = an - a1+1;
long long now_min = a1;
long long ans = 0;
rep(i, n) {
long long mn, mx;
MinMax(a1 + (X*i) / N, a1 + (X*(i + 1)) / N, mn,mx);
if (mn != -1) {
ans = max(mn - now_min, ans);
now_min = mx;
}
}
return ans;
}
int main() {
int n; cin >> n;
a = vel(n);
rep(i, n) { cin >> a[i]; }
ll ans=findGap(0, n);
cout << co << " " << ans;
return 0;
}
Compilation message
/tmp/cca5VzpI.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccFOQr0C.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status