Submission #390928

#TimeUsernameProblemLanguageResultExecution timeMemory
390928BlagojceGap (APIO16_gap)C++11
53.51 / 100
85 ms1096 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int mxn = 1e5; #include "gap.h" /* int n; ll A[mxn]; void MinMax(ll s, ll t, ll *mn, ll *mx){ *mn = -1; *mx = -1; fr(i, 0, n){ if(A[i] >= s){ if(A[i] <= t) *mn = A[i]; break; } } for(int i = n-1; i >= 0; i --){ if(A[i] <= t){ if(A[i] >= s) *mx = A[i]; break; } } } */ long long findGap(int T, int N) { ll a1, an; MinMax(0, 1e18, &a1, &an); ll d = (an - a1)/(N-1); ll pr = a1; ll ans = 0; for(int i = 0; i*d <= an; i++){ ll ai, aj; MinMax(i*d, min((i+1)*d-1, an), &ai, &aj); if(ai != -1){ ans = max(ans, ai-pr); pr = aj; } } return ans; } /* int main(){ cin >> n; fr(i, 0, n) cin >> A[i]; cout<<findGap(2, n)<<endl; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...