Submission #485154

#TimeUsernameProblemLanguageResultExecution timeMemory
485154MilosMilutinovicGap (APIO16_gap)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ff(i,a,b) for(int i = (a); (i) <= (b); ++(i)) #define fb(i,a,b) for(int i = (a); (i) >= (b); --(i)) #define pb push_back #define ll long long using namespace std; int n; ll a[50]; void MinMax(ll l, ll r, ll& x, ll& y){ x = 1e9; y = -1; ff(i,1,n){ if(a[i] >= l && a[i] <= r)x = min(x, a[i]); if(a[i] >= l && a[i] <= r)y = max(y, a[i]); } if(x == 1e9)x = -1; } ll findGap(int t, int n){ if(t == 1){ vector<ll> niz; ll l,r; MinMax(0, 1e18, l, r); niz.pb(l); niz.pb(r); while(l != -1 && l != r){ MinMax(l + 1, r - 1, l, r); niz.pb(l); if(l != r)niz.pb(r); } sort(niz.begin(), niz.end()); ll ans = 0; ff(i,0,n-1)ans = max(ans, niz[i + 1] - niz[i]); return ans; } else{ vector<ll> niz; ll l,r; MinMax(0, 1e18, l, r); if(n == 2)return r - l; niz.pb(l); niz.pb(r); ll d = (r - l + n - 3) / (n - 2); for(ll i = l + 1; i < r; i += d){ ll x,y; MinMax(i, i + d - 1, x, y); if(x != -1)niz.pb(x); if(y != -1 && x != y)niz.pb(y); } sort(niz.begin(), niz.end()); niz.erase(unique(niz.begin(), niz.end()), niz.end()); ll ans = 0; ff(i,0,niz.size()-1)ans = max(ans, niz[i + 1] - niz[i]); return ans; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; ff(i,1,n)cin >> a[i]; cout << findGap(2, n); return 0; }

Compilation message (stderr)

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:2:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    2 | #define ff(i,a,b) for(int i = (a); (i) <= (b); ++(i))
      |                                    ~~~~^~~~~~
gap.cpp:56:3: note: in expansion of macro 'ff'
   56 |   ff(i,0,niz.size()-1)ans = max(ans, niz[i + 1] - niz[i]);
      |   ^~
/usr/bin/ld: /tmp/ccNmlb8S.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccrFyktT.o:gap.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status