Submission #1031351

# Submission time Handle Problem Language Result Execution time Memory
1031351 2024-07-22T18:25:35 Z deera Rice Hub (IOI11_ricehub) C++14
0 / 100
2 ms 604 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int X[], long long B) {
    int max_rice = 0;
    for (int i = 0; i < R; i++) {
        int c = X[i];
        int l = i, r = i + 1;
        int q = B;
        int t = 0;


        if (l >= 0 && r <= R - 1) {
            int l_cost = abs(c - X[l]);
            int r_cost = abs(c - X[r]);

            if (min(l_cost, r_cost) > q) {
                max_rice = max(t, max_rice);
                continue;
            }

            if (l_cost <= r_cost) {
                t++;
                l--;
                q -= l_cost;
            } else {
                t++;
                r++;
                q -= r_cost;
            }
        } else if (r <= R - 1) { 
            // can't go left
            int r_cost = abs(c - X[r]);
            if (r_cost > q) {
                max_rice = max(t, max_rice);
                continue;
            }

            t++;
            r++;
            q -= r_cost;
        } else if (l >= 0) {
            int l_cost = abs(c - X[l]);
            if (l_cost > q) {
                max_rice = max(t, max_rice);
                continue;
            }

            t++;
            l--;
            q -= l_cost;
        } else {
            max_rice = max(t, max_rice);
            continue;
        }
    }

    return max_rice;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -