Submission #49754

# Submission time Handle Problem Language Result Execution time Memory
49754 2018-06-02T17:59:59 Z gs13105 Rice Hub (IOI11_ricehub) C++17
49 / 100
32 ms 1020 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
//#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    int p = 0, q = 0, res = 0;
    long long c = 0;
    for(int i = 0; i < R; i++)
    {
        if(i)
            c += 1LL * ((i - p) - (q - i)) * (X[i] - X[i - 1]);

        while(c > B)
        {
            assert(p < R);
            c -= X[i] - X[p++];
        }

        while(q < R && (X[q] - X[i] <= X[i] - X[p] || c + X[q] - X[i] <= B))
        {
            c += X[q++] - X[i];
            if(c > B)
            {
                assert(p < R);
                c -= X[i] - X[p++];
                assert(c <= B);
            }
        }

        assert(c <= B);
        res = max(res, q - p);
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 592 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 22 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 2 ms 636 KB Output is correct
27 Incorrect 3 ms 640 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
3 Correct 3 ms 640 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 2 ms 640 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct
11 Correct 3 ms 640 KB Output is correct
12 Correct 2 ms 640 KB Output is correct
13 Correct 3 ms 640 KB Output is correct
14 Correct 2 ms 640 KB Output is correct
15 Correct 2 ms 640 KB Output is correct
16 Correct 2 ms 640 KB Output is correct
17 Correct 3 ms 640 KB Output is correct
18 Incorrect 2 ms 640 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 18 ms 1020 KB Output is correct
4 Correct 20 ms 1020 KB Output is correct
5 Correct 12 ms 1020 KB Output is correct
6 Correct 11 ms 1020 KB Output is correct
7 Correct 26 ms 1020 KB Output is correct
8 Correct 17 ms 1020 KB Output is correct
9 Correct 9 ms 1020 KB Output is correct
10 Correct 8 ms 1020 KB Output is correct
11 Correct 20 ms 1020 KB Output is correct
12 Correct 23 ms 1020 KB Output is correct
13 Correct 12 ms 1020 KB Output is correct
14 Correct 11 ms 1020 KB Output is correct
15 Correct 21 ms 1020 KB Output is correct
16 Correct 18 ms 1020 KB Output is correct
17 Correct 21 ms 1020 KB Output is correct
18 Correct 27 ms 1020 KB Output is correct
19 Correct 32 ms 1020 KB Output is correct
20 Correct 23 ms 1020 KB Output is correct