# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
600730 | 2022-07-21T07:30:31 Z | 반딧불(#8467) | Long Distance Coach (JOI17_coach) | C++17 | 1032 ms | 262144 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct Person{ ll off, cost; Person(){} Person(ll off, ll cost): off(off), cost(cost){} bool operator<(const Person &r)const{ return off < r.off; } }; ll X, W, T; int n, k; ll arr[200002]; Person person[200002]; ll DP[200002]; ll ans = 9e18; vector<pair<int, ll> > link[200002]; int main(){ scanf("%lld %d %d %lld %lld", &X, &k, &n, &W, &T); for(int i=1; i<=k; i++) scanf("%lld", &arr[i]); sort(arr+1, arr+k+1); arr[++k] = X; for(int i=1; i<=n; i++) scanf("%lld %lld", &person[i].off, &person[i].cost); sort(person+1, person+n+1); DP[0] = (X / T + 1) * W; for(int i=1; i<=n; i++){ DP[i] = 9e18; link[i-1].push_back(make_pair(i, (X - person[i].off + T) / T * W)); } for(int i=1; i<=k; i++){ /// ���� ������ ��ȣ vector<pair<ll, int> > last; ll now = arr[i]; for(int j=1; j<=n; j++){ if(now%T < person[j].off || (now - now%T + person[j].off < arr[i-1])) continue; last.push_back(make_pair(now - (now%T - person[j].off), j)); } if(last.empty()) continue; sort(last.rbegin(), last.rend()); /// ������ prefix�� ���� ���� int endpoint = last[0].second; ll weight = 0; for(int s=0; s<(int)last.size(); s++){ int x = last[s].second; weight += (last[s].first - 1 - person[x].off + T) / T * W + person[x].cost; link[x-1].push_back(make_pair(endpoint, weight)); } } for(int i=0; i<n; i++){ for(pair<int, ll> p: link[i]){ DP[p.first] = min(DP[p.first], DP[i] + p.second); } } printf("%lld", DP[n]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 5008 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 4 ms | 4988 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 5016 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 5004 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 5012 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 4 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5004 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 5008 KB | Output is correct |
22 | Correct | 3 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 5008 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 4 ms | 4988 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 5016 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 5004 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 5012 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 4 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5004 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 5008 KB | Output is correct |
22 | Correct | 3 ms | 4948 KB | Output is correct |
23 | Correct | 4 ms | 5136 KB | Output is correct |
24 | Correct | 3 ms | 5076 KB | Output is correct |
25 | Correct | 3 ms | 5076 KB | Output is correct |
26 | Correct | 3 ms | 5140 KB | Output is correct |
27 | Correct | 3 ms | 5116 KB | Output is correct |
28 | Correct | 4 ms | 5140 KB | Output is correct |
29 | Correct | 3 ms | 5076 KB | Output is correct |
30 | Correct | 3 ms | 5076 KB | Output is correct |
31 | Correct | 4 ms | 5136 KB | Output is correct |
32 | Correct | 4 ms | 5076 KB | Output is correct |
33 | Correct | 4 ms | 5076 KB | Output is correct |
34 | Correct | 4 ms | 5136 KB | Output is correct |
35 | Correct | 3 ms | 5012 KB | Output is correct |
36 | Correct | 3 ms | 5076 KB | Output is correct |
37 | Correct | 3 ms | 5140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 5008 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 4 ms | 4988 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 5016 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 5004 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 5012 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 4 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5004 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 5008 KB | Output is correct |
22 | Correct | 3 ms | 4948 KB | Output is correct |
23 | Correct | 4 ms | 5136 KB | Output is correct |
24 | Correct | 3 ms | 5076 KB | Output is correct |
25 | Correct | 3 ms | 5076 KB | Output is correct |
26 | Correct | 3 ms | 5140 KB | Output is correct |
27 | Correct | 3 ms | 5116 KB | Output is correct |
28 | Correct | 4 ms | 5140 KB | Output is correct |
29 | Correct | 3 ms | 5076 KB | Output is correct |
30 | Correct | 3 ms | 5076 KB | Output is correct |
31 | Correct | 4 ms | 5136 KB | Output is correct |
32 | Correct | 4 ms | 5076 KB | Output is correct |
33 | Correct | 4 ms | 5076 KB | Output is correct |
34 | Correct | 4 ms | 5136 KB | Output is correct |
35 | Correct | 3 ms | 5012 KB | Output is correct |
36 | Correct | 3 ms | 5076 KB | Output is correct |
37 | Correct | 3 ms | 5140 KB | Output is correct |
38 | Correct | 110 ms | 42316 KB | Output is correct |
39 | Correct | 110 ms | 43112 KB | Output is correct |
40 | Correct | 119 ms | 46584 KB | Output is correct |
41 | Correct | 109 ms | 42316 KB | Output is correct |
42 | Correct | 116 ms | 44432 KB | Output is correct |
43 | Correct | 91 ms | 38728 KB | Output is correct |
44 | Correct | 124 ms | 45292 KB | Output is correct |
45 | Correct | 109 ms | 44236 KB | Output is correct |
46 | Correct | 124 ms | 41652 KB | Output is correct |
47 | Correct | 110 ms | 46156 KB | Output is correct |
48 | Correct | 112 ms | 45068 KB | Output is correct |
49 | Correct | 37 ms | 5208 KB | Output is correct |
50 | Correct | 109 ms | 42752 KB | Output is correct |
51 | Correct | 103 ms | 43956 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4948 KB | Output is correct |
2 | Correct | 3 ms | 5008 KB | Output is correct |
3 | Correct | 3 ms | 5008 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 3 ms | 4948 KB | Output is correct |
6 | Correct | 4 ms | 4988 KB | Output is correct |
7 | Correct | 3 ms | 4948 KB | Output is correct |
8 | Correct | 3 ms | 5016 KB | Output is correct |
9 | Correct | 3 ms | 4948 KB | Output is correct |
10 | Correct | 3 ms | 5004 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 4 ms | 4948 KB | Output is correct |
14 | Correct | 3 ms | 5012 KB | Output is correct |
15 | Correct | 3 ms | 4948 KB | Output is correct |
16 | Correct | 4 ms | 4948 KB | Output is correct |
17 | Correct | 4 ms | 4948 KB | Output is correct |
18 | Correct | 3 ms | 4948 KB | Output is correct |
19 | Correct | 4 ms | 5004 KB | Output is correct |
20 | Correct | 3 ms | 4948 KB | Output is correct |
21 | Correct | 3 ms | 5008 KB | Output is correct |
22 | Correct | 3 ms | 4948 KB | Output is correct |
23 | Correct | 4 ms | 5136 KB | Output is correct |
24 | Correct | 3 ms | 5076 KB | Output is correct |
25 | Correct | 3 ms | 5076 KB | Output is correct |
26 | Correct | 3 ms | 5140 KB | Output is correct |
27 | Correct | 3 ms | 5116 KB | Output is correct |
28 | Correct | 4 ms | 5140 KB | Output is correct |
29 | Correct | 3 ms | 5076 KB | Output is correct |
30 | Correct | 3 ms | 5076 KB | Output is correct |
31 | Correct | 4 ms | 5136 KB | Output is correct |
32 | Correct | 4 ms | 5076 KB | Output is correct |
33 | Correct | 4 ms | 5076 KB | Output is correct |
34 | Correct | 4 ms | 5136 KB | Output is correct |
35 | Correct | 3 ms | 5012 KB | Output is correct |
36 | Correct | 3 ms | 5076 KB | Output is correct |
37 | Correct | 3 ms | 5140 KB | Output is correct |
38 | Correct | 110 ms | 42316 KB | Output is correct |
39 | Correct | 110 ms | 43112 KB | Output is correct |
40 | Correct | 119 ms | 46584 KB | Output is correct |
41 | Correct | 109 ms | 42316 KB | Output is correct |
42 | Correct | 116 ms | 44432 KB | Output is correct |
43 | Correct | 91 ms | 38728 KB | Output is correct |
44 | Correct | 124 ms | 45292 KB | Output is correct |
45 | Correct | 109 ms | 44236 KB | Output is correct |
46 | Correct | 124 ms | 41652 KB | Output is correct |
47 | Correct | 110 ms | 46156 KB | Output is correct |
48 | Correct | 112 ms | 45068 KB | Output is correct |
49 | Correct | 37 ms | 5208 KB | Output is correct |
50 | Correct | 109 ms | 42752 KB | Output is correct |
51 | Correct | 103 ms | 43956 KB | Output is correct |
52 | Runtime error | 1032 ms | 262144 KB | Execution killed with signal 9 |
53 | Halted | 0 ms | 0 KB | - |