Submission #856474

# Submission time Handle Problem Language Result Execution time Memory
856474 2023-10-03T15:57:38 Z nnin Rice Hub (IOI11_ricehub) C++14
68 / 100
10 ms 3684 KB
#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,int>
using namespace std;

int besthub(int n, int m, int x[], long long b) {
    int ans = 0;
    ll cost = 0;
    int l = 0;
    int r = 0;
    for(int i=0;i<n;i++) {
        if(i>0) cost += (x[i]-x[i-1])*(i-l-r+i-1);
        if(r<i) {
            cost += x[++r]-x[i];
        }
        while(cost>b) {
            if(x[r]-x[i] > x[i]-x[l]) {
                cost -= x[r--]-x[i];
            } else {
                cost -= x[i]-x[l++];
            }
        }
        while(true) {
            if(r<n-1 && x[r+1]-x[i] <= x[i]-x[l]) {
                cost += x[++r]-x[i];
                cost -= x[i]-x[l++];
            } else if(l>0 && x[i]-x[l-1] < x[r]-x[i]) {
                cost += x[i]-x[--l];
                cost -= x[r--]-x[i];
            } else if(r<n-1 && cost+x[r+1]-x[i] <= b) {
                cost += x[++r]-x[i];
            } else if(l>0 && cost+x[i]-x[l-1] <= b) {
                cost += x[i]-x[--l];
            } else {
                break;
            }
        }
        ans = max(ans, r-l+1);
    }
    return ans;
}
/*
5 20 6
1
2
10
12
14
3

*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 448 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 452 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 444 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 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 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 448 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 448 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 448 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 1 ms 348 KB Output is correct
11 Correct 1 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 1 ms 348 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 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 500 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 10 ms 3684 KB Output is correct
4 Correct 10 ms 3672 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 3000 KB Output is correct
7 Correct 8 ms 3420 KB Output is correct
8 Correct 9 ms 3428 KB Output is correct
9 Correct 4 ms 2908 KB Output is correct
10 Correct 4 ms 2904 KB Output is correct
11 Correct 10 ms 3676 KB Output is correct
12 Incorrect 10 ms 3676 KB Output isn't correct
13 Halted 0 ms 0 KB -