8806 | 2024-01-31 10:02:58 | Error42 | Rendőrségi Üldözés 4 | cpp17 | Wrong answer 25/100 | 492ms | 5404 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";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2028 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 3ms | 2232 KiB | ||||
4 | Accepted | 3ms | 2448 KiB | ||||
5 | Accepted | 3ms | 2668 KiB | ||||
6 | Accepted | 3ms | 2880 KiB | ||||
7 | Accepted | 3ms | 3116 KiB | ||||
subtask3 | 15/15 | ||||||
8 | Accepted | 3ms | 3192 KiB | ||||
9 | Accepted | 3ms | 3412 KiB | ||||
10 | Accepted | 3ms | 3420 KiB | ||||
11 | Accepted | 3ms | 3552 KiB | ||||
subtask4 | 0/15 | ||||||
12 | Wrong answer | 3ms | 3652 KiB | ||||
13 | Accepted | 3ms | 3632 KiB | ||||
14 | Wrong answer | 3ms | 3624 KiB | ||||
15 | Wrong answer | 3ms | 4012 KiB | ||||
subtask5 | 0/25 | ||||||
16 | Wrong answer | 3ms | 4008 KiB | ||||
17 | Wrong answer | 3ms | 3996 KiB | ||||
18 | Wrong answer | 3ms | 4096 KiB | ||||
19 | Wrong answer | 3ms | 3912 KiB | ||||
20 | Wrong answer | 3ms | 4024 KiB | ||||
subtask6 | 0/15 | ||||||
21 | Wrong answer | 3ms | 4068 KiB | ||||
22 | Wrong answer | 3ms | 4320 KiB | ||||
23 | Wrong answer | 3ms | 4476 KiB | ||||
24 | Wrong answer | 3ms | 4460 KiB | ||||
25 | Wrong answer | 3ms | 4424 KiB | ||||
subtask7 | 0/20 | ||||||
26 | Wrong answer | 8ms | 4628 KiB | ||||
27 | Wrong answer | 20ms | 4888 KiB | ||||
28 | Wrong answer | 54ms | 5104 KiB | ||||
29 | Wrong answer | 166ms | 5300 KiB | ||||
30 | Wrong answer | 492ms | 5404 KiB |