Submission #1115164

#TimeUsernameProblemLanguageResultExecution timeMemory
1115164raspyRice Hub (IOI11_ricehub)C++17
68 / 100
14 ms5968 KiB
#include <bits/stdc++.h> #include "ricehub.h" #define ll long long #define vi vector<ll> #define ii pair<ll, ll> #define f first #define s second #define all(x) (x).begin(), (x).end() #define P 31 #define mod 1'000'000'007 #define inf 1'000'000'000'000'000'0 #define pb push_back #define str string #define sz(x) (x).size() #define vvi vector<vi> #define fun function #define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define file freopen("problemname.in", "r", stdin); freopen("pr.out", "w", stdout); #define dbg(v) cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; template <class T, int SZ> using arr = array<T, SZ>; int besthub(int r, int l, int x[], long long b) { vi kum(r+1); vi kum1(r+1); for (ll i = 1; i <= r; i++) kum[i] = kum[i-1]+x[i-1]; for (ll i = r-1; i >= 0; i--) kum1[i] = kum1[i+1]+l-x[i]; deque<ll> dq; ll rez = 0; auto calcprice = [&dq, &kum, &kum1, &x, &l]() { ll med = dq[dq.size()/2]; int std = dq.size()-dq.size()/2-1; int stl = dq.size()/2; ll tr = kum[dq.back()+1]-kum[med+1]-x[med]*std; tr = tr+kum1[dq[0]]-kum1[med]-(l-x[med])*stl; return tr; }; for (ll i = 0; i < r; i++) { dq.pb(i); ll trc = calcprice(); while (trc > b) { dq.pop_front(); trc = calcprice(); } rez = max(rez, (ll)dq.size()); } return rez; } // #include <stdio.h> // #include <stdlib.h> // #define MAX_R 1000000 // static int R, L; // static long long B; // static int X[MAX_R]; // static int solution; // inline // void my_assert(int e) {if (!e) abort();} // static void read_input() // { // int i; // my_assert(3==scanf("%d %d %lld",&R,&L,&B)); // for(i=0; i<R; i++) // my_assert(1==scanf("%d",&X[i])); // my_assert(1==scanf("%d",&solution)); // } // int main() // { // int ans; // read_input(); // ans = besthub(R,L,X,B); // if(ans==solution) // printf("Correct.\n"); // else // printf("Incorrect. Returned %d instead of %d.\n",ans,solution); // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...