88062024-01-31 10:02:58Error42Rendőrségi Üldözés 4cpp17Wrong answer 25/100492ms5404 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

ll first_green(ll const cur_t, ll const t) {
    ll cycle = cur_t % (2 * t);

    if (cycle < t)
        return cur_t;
    else
        return cur_t / (2 * t) * (2 * t) + 2 * t;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, r, t, l;
    cin >> n >> r >> t >> l;

    vector<ll> x(n);
    for (ll& y : x)
        cin >> y;

    vector<ll> dp(r + 1);

    for (int i = 0; i <= r; i++)
        dp[i] = x[0];

    for (int i = 0; i < n; i++) {
        // get through lamp
        for (int j = 1; j <= r; j++) {
            dp[j] = min(first_green(dp[j], t), dp[j - 1]);
        }
        dp[0] = first_green(dp[0], t);

        // to next lamp
        if (i != n - 1) {
            for (int j = 0; j <= r; j++)
                dp[j] += x[i + 1] - x[i];
        }
    }

    cout << dp[r] + l - x.back() << "\n";
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2028 KiB
subtask210/10
3Accepted3ms2232 KiB
4Accepted3ms2448 KiB
5Accepted3ms2668 KiB
6Accepted3ms2880 KiB
7Accepted3ms3116 KiB
subtask315/15
8Accepted3ms3192 KiB
9Accepted3ms3412 KiB
10Accepted3ms3420 KiB
11Accepted3ms3552 KiB
subtask40/15
12Wrong answer3ms3652 KiB
13Accepted3ms3632 KiB
14Wrong answer3ms3624 KiB
15Wrong answer3ms4012 KiB
subtask50/25
16Wrong answer3ms4008 KiB
17Wrong answer3ms3996 KiB
18Wrong answer3ms4096 KiB
19Wrong answer3ms3912 KiB
20Wrong answer3ms4024 KiB
subtask60/15
21Wrong answer3ms4068 KiB
22Wrong answer3ms4320 KiB
23Wrong answer3ms4476 KiB
24Wrong answer3ms4460 KiB
25Wrong answer3ms4424 KiB
subtask70/20
26Wrong answer8ms4628 KiB
27Wrong answer20ms4888 KiB
28Wrong answer54ms5104 KiB
29Wrong answer166ms5300 KiB
30Wrong answer492ms5404 KiB