This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include "ricehub.h"
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
using namespace std;
int a[1 << 17];
int besthub(int n, int useless, int v[], long long B)
{
# define int ll
int l = 1;
int r = n;
for(int i = 1;i <= n;i++)
{
a[i] = v[i - 1];
a[i] += a[i - 1];
}
while(l < r)
{
int len = (l + r + 1) / 2;
bool ok = 0;
for(int i = len;i <= n;i++)
{
int L = i - len + 1;
int R = i;
int mid = (L + R) / 2;
int f = 0;
f += 1LL * (a[mid] - a[mid - 1]) * (mid - L) - a[mid - 1] + a[L - 1];
if(f > 1e18) continue;
f += a[R] - a[mid] - 1LL * (a[mid] - a[mid - 1]) * (R - mid);
if(f <= B) ok = 1;
}
if(ok) l = len;
else r = len - 1;
}
return l;
}
Compilation message (stderr)
ricehub.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
# pragma GCC optimization ("unroll-loops")
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |