Submission #336052

# Submission time Handle Problem Language Result Execution time Memory
336052 2020-12-14T14:59:12 Z aryan12 Rice Hub (IOI11_ricehub) C++17
100 / 100
15 ms 1772 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

int besthub(int r, int l, int x[], long long b) {
    long long left = 0, right = 0, ans = 0;
    long long curCost = 0;
    while(left < r) {
        if(right >= r)
            break;
        long long OptimalField = (left + right) / 2;
        //cout << left << " " << right << " " << OptimalField << " " << curCost << endl;
        if(curCost + x[right] - x[OptimalField] <= b) {
            curCost += x[right] - x[OptimalField];
            ans = max(ans, right - left + 1);
            right++;
        }
        else {
            curCost -= x[OptimalField] - x[left++];
        }
    }
    return ans;
}
/*
int main() {
    //cout << "Input the number of rice fields" << endl;
    int r;
    cin >> r;
    //cout << "Input the maaimum coordinate" << endl;
    int l;
    cin >> l;
    //cout << "Input r numbers, denoting the rice fields" << endl;
    int a[r];
    for(int i = 0; i < r; i++) {
        cin >> a[i];
    }
    //cout << "Input the budget" << endl;
    int b;
    cin >> b;
    cout << besthub(r, l, a, b) << endl;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Correct 14 ms 748 KB Output is correct
4 Correct 14 ms 748 KB Output is correct
5 Correct 7 ms 876 KB Output is correct
6 Correct 7 ms 876 KB Output is correct
7 Correct 13 ms 1516 KB Output is correct
8 Correct 13 ms 1516 KB Output is correct
9 Correct 6 ms 876 KB Output is correct
10 Correct 6 ms 748 KB Output is correct
11 Correct 15 ms 1772 KB Output is correct
12 Correct 15 ms 1772 KB Output is correct
13 Correct 7 ms 876 KB Output is correct
14 Correct 7 ms 876 KB Output is correct
15 Correct 11 ms 1388 KB Output is correct
16 Correct 12 ms 1388 KB Output is correct
17 Correct 13 ms 1644 KB Output is correct
18 Correct 13 ms 1644 KB Output is correct
19 Correct 14 ms 1644 KB Output is correct
20 Correct 15 ms 1644 KB Output is correct