Submission #1084908

# Submission time Handle Problem Language Result Execution time Memory
1084908 2024-09-07T08:10:47 Z PakinDioxide Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 3024 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int l = 1, r = 0;
vector <pair <int, int>> p;

long long recal() {
    long long sum = 0;
    int ll = l, rr = r;
    while (ll < rr) sum += p[rr--].first - p[ll++].first;
    return sum;
}

int besthub(int n, int m, int a[], long long x) {
    p.emplace_back(0, 0);
    for (int j = 0; j < n; j++) {
        int i = a[j];
        p.emplace_back(i, p[p.size()-1].second + 1);
        // if (p[p.size()-1].first != i) p.emplace_back(i, p[p.size()-1].second + 1);
        // else p[p.size()-1].second++;
    }
    // for (auto [x, y] : p) printf("%d %d\n", x, y);
    // printf("S %d\n", p.size());
    int mx = 0;
    while (r < p.size() - 1) {
        r++;
        while (recal() > x) l++;
        mx = max(mx, p[r].second - p[l-1].second);
        // printf("MX %d\n", mx);
    }
    return mx;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:27:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (r < p.size() - 1) {
      |            ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 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 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 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 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 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 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 1 ms 348 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 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 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 1 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 1 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 348 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 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 5 ms 488 KB Output is correct
24 Correct 5 ms 600 KB Output is correct
25 Correct 5 ms 604 KB Output is correct
26 Correct 5 ms 604 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Execution timed out 1053 ms 3024 KB Time limit exceeded
4 Halted 0 ms 0 KB -