Submission #725945

# Submission time Handle Problem Language Result Execution time Memory
725945 2023-04-18T09:13:25 Z adrilen Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 2884 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;



int besthub(int n, int L, int X[], long long b)
{
    vector <ll> fields;
    for (int i = 0; i < n; i++) fields.emplace_back(X[i]);

    ll cur = 0;
    if (n == 1) return 1;
    int output = 0;

    ll p;
    int left, right;
    for (int i = 0; i < n; i++)
    {
        p = fields[i];
        cur = b;
        left = i - 1, right = i + 1;

        while (true)
        {
            if (left < 0 && right == n)
            {
                break;
            } else if (left < 0)
            {   
                if (cur >= fields[right] - p) {
                    cur -= fields[right] - p;
                    right++;
                } else break;
            } else if (right == n)
            {
                if (cur >= p - fields[left]) {
                    cur -= p - fields[left];
                    left--;
                } else break;
            }
            else if (p - fields[left] < fields[right] - p)
            {
                if (cur >= p - fields[left]) {
                    cur -= p - fields[left];
                    left--;
                } else break;
            } else {
                if (cur >= fields[right] - p) {
                    cur -= fields[right] - p;
                    right++;
                } else break;
            }
        }
        output = max(output, right - left - 1);
    }


    return output;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 2 ms 212 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 2 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 3 ms 320 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 4 ms 212 KB Output is correct
20 Correct 5 ms 212 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 43 ms 340 KB Output is correct
24 Correct 34 ms 448 KB Output is correct
25 Correct 92 ms 468 KB Output is correct
26 Correct 85 ms 468 KB Output is correct
27 Correct 23 ms 448 KB Output is correct
28 Correct 25 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 840 KB Output is correct
2 Correct 5 ms 812 KB Output is correct
3 Execution timed out 1072 ms 2884 KB Time limit exceeded
4 Halted 0 ms 0 KB -