Submission #677567

# Submission time Handle Problem Language Result Execution time Memory
677567 2023-01-03T17:48:14 Z ThegeekKnight16 Rice Hub (IOI11_ricehub) C++17
68 / 100
1000 ms 632 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
    int resp = 0;

    for (int i = 1; i <= R; i++)
    {

        int p = i; int q = i+1;
        long long sum = 0; int respi = 0;
        while (p >= 1 && q <= R)
        {
            long long desq = abs(X[i] - X[p]); long long ddir = abs(X[q] - X[i]);
            if (desq < ddir)
            {
                if (sum + desq > B) break;
                sum += desq;
                p--;
                respi++;
            }
            else
            {
                if (sum + ddir > B) break;
                sum += ddir;
                q++;
                respi++;
            }
        }

        while (p >= 1)
        {
            long long desq = abs(X[i] - X[p]);
            if (sum + desq > B) break;
            sum += desq;
            p--;
            respi++;
        }

        while (q <= R)
        {
            long long ddir = abs(X[q] - X[i]);
            if (sum + ddir > B) break;
            sum += ddir;
            q++;
            respi++;
        }

        // cerr << i << " " << sum << " " << respi << '\n';
        resp = max(resp, respi);
    }

    return resp;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 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 1 ms 212 KB Output is correct
20 Correct 0 ms 308 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 312 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 2 ms 320 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 312 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 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 316 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 5 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 340 KB Output is correct
23 Correct 49 ms 340 KB Output is correct
24 Correct 46 ms 340 KB Output is correct
25 Correct 102 ms 352 KB Output is correct
26 Correct 102 ms 348 KB Output is correct
27 Correct 32 ms 348 KB Output is correct
28 Correct 31 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Execution timed out 1078 ms 632 KB Time limit exceeded
4 Halted 0 ms 0 KB -