# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
306746 |
2020-09-26T08:32:55 Z |
syy |
Rice Hub (IOI11_ricehub) |
C++17 |
|
4 ms |
896 KB |
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, arr[100005], ss[100005], cost;
bool ok(ll k) {
FOR(i, 1, n-k+1) {
ll m = (i + i+k-1)/2;
if (cost >= (ss[i+k-1] - ss[m] - arr[m]*(i+k-m)) + (arr[m]*(m-i) + ss[m-1] - ss[i-1])) return 1;
}
return 0;
}
int besthub(int R, int L, int X[], ll B) {
n = R, cost = B;
FOR(i, 1, n) arr[i] = X[i-1];
FOR(i, 1, n) ss[i] = ss[i-1] + arr[i];
ll lower = 1, upper = n+1;
while (upper - lower > 1) {
ll mid = (upper + lower)/2;
if (ok(mid)) lower = mid;
else upper = mid;
}
return (int) lower;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |