Submission #714046

# Submission time Handle Problem Language Result Execution time Memory
714046 2023-03-23T17:21:03 Z Spade1 Rice Hub (IOI11_ricehub) C++14
49 / 100
14 ms 1184 KB
#include <bits/stdc++.h>
#define ll long long
#include "ricehub.h"
//#include "grader.cpp"

using namespace std;

queue<int> qL, qR;

int besthub(int R, int L, int X[], ll B) {
    ll cost = 0, cur = 1;
    int ans = 0;
    for (int i = 0; i < R; ++i) {
        if (i != 0) cost += (X[i]-X[i-1])*qL.size();
        if (i != 0) cost -= (X[i]-X[i-1])*qR.size();
        if (!qR.empty() && qR.front() == X[i]) qR.pop();
        if (cur <= i) cur++;
        qL.push(X[i]);
        while (cost > B) {
            cost -= X[i]-qL.front();
            qL.pop();
        }
        while (cur < R) {
            if (cost + X[cur] - X[i] > B) {
                if (cost - (X[i]-qL.front()) + (X[cur]-X[i]) <= cost) {
                    cost -= X[i]-qL.front();
                    cost += X[cur]-X[i];
                    qL.pop();
                    qR.push(X[cur++]);
                }
                else break;
            }
            else {
                cost += X[cur] - X[i];
                qR.push(X[cur++]);
            }
        }
        int curr = qL.size() + qR.size();
        ans = max(ans, curr);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 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 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Incorrect 0 ms 212 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 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 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 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 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 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 14 ms 1108 KB Output is correct
4 Correct 12 ms 1108 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 6 ms 456 KB Output is correct
7 Correct 10 ms 1108 KB Output is correct
8 Correct 10 ms 1144 KB Output is correct
9 Correct 5 ms 544 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 11 ms 1036 KB Output is correct
12 Correct 12 ms 1184 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 6 ms 464 KB Output is correct
15 Correct 9 ms 852 KB Output is correct
16 Correct 13 ms 900 KB Output is correct
17 Correct 12 ms 1036 KB Output is correct
18 Correct 11 ms 980 KB Output is correct
19 Correct 13 ms 1120 KB Output is correct
20 Correct 13 ms 1012 KB Output is correct