Submission #477019

# Submission time Handle Problem Language Result Execution time Memory
477019 2021-09-29T19:29:48 Z Mher Rice Hub (IOI11_ricehub) C++14
100 / 100
24 ms 3336 KB
#include "ricehub.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <bitset>
 
using namespace std;
 
const int N = 200003;
 
long long r, l, b;
long long x[N], p[N];
 
long long sum(int xl, int xr)
{
    return max(0ll, p[xr] - p[xl - 1]);
}
 
long long cost(int xl, int xr)
{
    int xm = (xl + xr) / 2;
    return sum(xm + 1, xr) - sum(xl, xm - ((xr - xl) % 2 == 0));
}
 
long long search(int ind)
{
    int xl = ind, xr = r;
    while (xl < xr)
    {
        int xm = (xl + xr + 1) / 2;
        if (cost(ind, xm) <= b)
        {
            xl = xm;
        }
        else
        {
            xr = xm - 1;
        }
    }
    return xl - ind + 1;
}
 
int besthub(int R, int L, int X[], long long B) {
	r = R;
  	l = L;
  	b = B;
    for (int i = 1; i <= r; i++)
    {
        x[i] = X[i - 1];
    }
    for (int i = 1; i <= r; i++)
    {
        p[i] = x[i] + p[i - 1];
    }
    long long ans = 0;
    for (int i = 1; i <= r; i++)
    {
        ans = max(ans, search(i));
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 448 KB Output is correct
28 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 844 KB Output is correct
2 Correct 4 ms 844 KB Output is correct
3 Correct 24 ms 3228 KB Output is correct
4 Correct 20 ms 3264 KB Output is correct
5 Correct 9 ms 1612 KB Output is correct
6 Correct 12 ms 1612 KB Output is correct
7 Correct 16 ms 3040 KB Output is correct
8 Correct 22 ms 2944 KB Output is correct
9 Correct 11 ms 1504 KB Output is correct
10 Correct 13 ms 1584 KB Output is correct
11 Correct 18 ms 3276 KB Output is correct
12 Correct 18 ms 3336 KB Output is correct
13 Correct 13 ms 1612 KB Output is correct
14 Correct 13 ms 1648 KB Output is correct
15 Correct 13 ms 2508 KB Output is correct
16 Correct 13 ms 2488 KB Output is correct
17 Correct 16 ms 2968 KB Output is correct
18 Correct 17 ms 3000 KB Output is correct
19 Correct 17 ms 3148 KB Output is correct
20 Correct 19 ms 3156 KB Output is correct