Submission #431599

# Submission time Handle Problem Language Result Execution time Memory
431599 2021-06-17T13:27:04 Z oolimry Long Distance Coach (JOI17_coach) C++17
71 / 100
250 ms 86084 KB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define tern(cond, a, b) (cond ? a : b)
typedef long long lint;
typedef pair<lint,lint> ii;
	
lint X, n, m, W, T;
lint S[2005];
lint C[2005];
vector<ii> bruh;
lint points[2005];
lint bestmods[2005];

unordered_map<lint,lint> dp[2005];
lint nth[2005];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	fill(bestmods, bestmods+2001, 102345678901234LL);
	cin >> X >> m >> n >> W >> T;
	for(int i = 1;i <= m;i++){
		cin >> points[i];
	}
	points[m+1] = X;
	
	for(int i = 1;i <= n;i++){
		cin >> S[i] >> C[i];
		bruh.push_back({S[i], C[i]});
	}
	sort(all(bruh));
	for(int i = 1;i <= n;i++){
		S[i] = bruh[i-1].first;
		C[i] = bruh[i-1].second;
	}
	
	for(int i = 1;i <= m+1;i++){
		lint a = points[i] % T, b = points[i] / T;
		a = lower_bound(S+1, S+n+1, a) - (S);
		a--;
		bestmods[a] = min(bestmods[a], b);
	}
	
	nth[n+1] = 0LL;
	for(int i = n;i >= 1;i--){
		lint besthere = nth[i+1];
		for(ii p : dp[i+1]){
			besthere = min(besthere, p.second);
			
			dp[i][p.first] = p.second + C[i] + p.first * W;
		}
		
		if(bestmods[i] != 102345678901234LL){
			dp[i][bestmods[i]] = besthere + C[i] + bestmods[i] * W;
		}
		
		lint cnt = X / T;
		if(X % T > S[i]) cnt++;
		nth[i] = besthere + W * cnt;
	}
	
	lint ans = nth[1];
	for(ii p : dp[1]) ans = min(ans, p.second);
	
	ans += W*(X/T+1);
	cout << ans;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 588 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 1 ms 572 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 588 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 588 KB Output is correct
32 Correct 1 ms 624 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 524 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 2 ms 448 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 588 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 1 ms 572 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 588 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 588 KB Output is correct
32 Correct 1 ms 624 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 524 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 2 ms 448 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 107 ms 39184 KB Output is correct
39 Correct 192 ms 76524 KB Output is correct
40 Correct 250 ms 86084 KB Output is correct
41 Correct 109 ms 40560 KB Output is correct
42 Correct 109 ms 41120 KB Output is correct
43 Correct 109 ms 39600 KB Output is correct
44 Correct 132 ms 43864 KB Output is correct
45 Correct 112 ms 42596 KB Output is correct
46 Correct 204 ms 86004 KB Output is correct
47 Correct 217 ms 84316 KB Output is correct
48 Correct 118 ms 41936 KB Output is correct
49 Correct 2 ms 844 KB Output is correct
50 Correct 107 ms 39932 KB Output is correct
51 Correct 125 ms 40668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 480 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 452 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 588 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 1 ms 572 KB Output is correct
28 Correct 1 ms 588 KB Output is correct
29 Correct 1 ms 588 KB Output is correct
30 Correct 1 ms 588 KB Output is correct
31 Correct 1 ms 588 KB Output is correct
32 Correct 1 ms 624 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 1 ms 524 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 2 ms 448 KB Output is correct
37 Correct 1 ms 596 KB Output is correct
38 Correct 107 ms 39184 KB Output is correct
39 Correct 192 ms 76524 KB Output is correct
40 Correct 250 ms 86084 KB Output is correct
41 Correct 109 ms 40560 KB Output is correct
42 Correct 109 ms 41120 KB Output is correct
43 Correct 109 ms 39600 KB Output is correct
44 Correct 132 ms 43864 KB Output is correct
45 Correct 112 ms 42596 KB Output is correct
46 Correct 204 ms 86004 KB Output is correct
47 Correct 217 ms 84316 KB Output is correct
48 Correct 118 ms 41936 KB Output is correct
49 Correct 2 ms 844 KB Output is correct
50 Correct 107 ms 39932 KB Output is correct
51 Correct 125 ms 40668 KB Output is correct
52 Runtime error 3 ms 972 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -