Submission #875016

# Submission time Handle Problem Language Result Execution time Memory
875016 2023-11-18T13:44:55 Z StefanL2005 Rice Hub (IOI11_ricehub) C++14
100 / 100
17 ms 4700 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long


int besthub(int R, int L, int X[], ll B)
{
    int ans = 1;
    vector<ll> Sum(R, 0);

    for (int i = 1; i < R; i++)
        Sum[i] = Sum[i - 1] + X[i] - X[0];

    for (int i = 0; i < R; i++)
    {
        int c1 = i, c2 = R - 1;

        while (c1 <= c2)
        {
            int m = (c1 + c2) / 2;
            int hub = (i + m) / 2;

            ll S = 0;
            S += 1LL * (X[hub] - X[i]) * (hub - i + 1) - (Sum[hub] - Sum[i] - 1LL * (hub - i) * (X[i] - X[0]));
            S += Sum[m] - Sum[hub] - 1LL * (m - hub) * (X[hub] - X[0]);

            if (S <= B)
            {
                ans = max(ans, m - i + 1);
                c1 = m + 1;
            }
            else
                c2 = m - 1;
        }
    }  
    
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 444 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 444 KB Output is correct
24 Correct 0 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 448 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 488 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 17 ms 4612 KB Output is correct
4 Correct 17 ms 4296 KB Output is correct
5 Correct 7 ms 3164 KB Output is correct
6 Correct 7 ms 3164 KB Output is correct
7 Correct 14 ms 4188 KB Output is correct
8 Correct 14 ms 4440 KB Output is correct
9 Correct 8 ms 3164 KB Output is correct
10 Correct 7 ms 3164 KB Output is correct
11 Correct 15 ms 4396 KB Output is correct
12 Correct 15 ms 4700 KB Output is correct
13 Correct 7 ms 3420 KB Output is correct
14 Correct 9 ms 3420 KB Output is correct
15 Correct 13 ms 3952 KB Output is correct
16 Correct 11 ms 3932 KB Output is correct
17 Correct 13 ms 4188 KB Output is correct
18 Correct 14 ms 4184 KB Output is correct
19 Correct 14 ms 4184 KB Output is correct
20 Correct 14 ms 4188 KB Output is correct