# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1114788 |
2024-11-19T15:42:45 Z |
raspy |
Rice Hub (IOI11_ricehub) |
C++17 |
|
3 ms |
1020 KB |
#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]+1;
// for (ll i = 0; i <= r; i++)
// cout << kum[i] << " \n"[i==r];
// for (ll i = r; i >= 0; i--)
// cout << kum1[i] << " \n"[i==0];
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 = kum1[dq[0]]-kum1[med]-(l-x[med])*stl;
// cout << dq.size() << " " << tr << "\n";
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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |