Submission #127867

# Submission time Handle Problem Language Result Execution time Memory
127867 2019-07-10T07:37:03 Z 김세빈(#3108) Long Distance Coach (JOI17_coach) C++14
71 / 100
2000 ms 15240 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

vector <pll> V[202020];
pll P[202020];
ll X[202020];
ll dp[202020];
ll x, n, m, w, k, ans;

int main()
{
	ll i, j, l, r, v, s;
	
	scanf("%lld%lld%lld%lld%lld", &x, &n, &m, &w, &k);
	
	for(i=1; i<=n; i++){
		scanf("%lld", X + i);
	}
	
	sort(X + 1, X + n + 1);
	
	X[++n] = x;
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld", &P[i].first, &P[i].second);
	}
	
	sort(P + 1, P + m + 1);
	
	for(i=1; i<=n; i++){
		if(X[i - 1] % k + (X[i] - X[i - 1]) < k){
			l = X[i - 1] % k + 1; r = X[i] % k; v = X[i] / k;
		}
		else{
			l = 1; r = X[i] % k; v = X[i] / k;
		}
		
		l = lower_bound(P + 1, P + m + 1, pll(l, -1)) - P;
		r = lower_bound(P + 1, P + m + 1, pll(r, 1e18)) - P - 1;
		if(r >= 1 && l <= r) V[r].emplace_back(l, v);
	}
	
	dp[0] = (x / k + 1) * w;
	
	for(i=1; i<=m; i++){
		if(P[i].first % k < x % k) dp[i] = dp[i - 1] + (x / k + 1) * w;
		else dp[i] = dp[i - 1] + x / k * w;
		
		for(pll &t: V[i]){
			for(j=i, s=0; j>=1 && j>=t.first; j--){
				s += P[j].second + w * t.second;
				dp[i] = min(dp[i], dp[j - 1] + s);
			}
		}
	}
	
	printf("%lld\n", dp[m]);
	
	return 0;
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld%lld%lld", &x, &n, &m, &w, &k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", X + i);
   ~~~~~^~~~~~~~~~~~~~~
coach.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &P[i].first, &P[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5108 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5112 KB Output is correct
12 Correct 6 ms 5164 KB Output is correct
13 Correct 6 ms 5116 KB Output is correct
14 Correct 6 ms 5112 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 6 ms 5092 KB Output is correct
17 Correct 6 ms 5112 KB Output is correct
18 Correct 6 ms 5112 KB Output is correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 6 ms 5112 KB Output is correct
22 Correct 6 ms 5116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5108 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5112 KB Output is correct
12 Correct 6 ms 5164 KB Output is correct
13 Correct 6 ms 5116 KB Output is correct
14 Correct 6 ms 5112 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 6 ms 5092 KB Output is correct
17 Correct 6 ms 5112 KB Output is correct
18 Correct 6 ms 5112 KB Output is correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 6 ms 5112 KB Output is correct
22 Correct 6 ms 5116 KB Output is correct
23 Correct 6 ms 5112 KB Output is correct
24 Correct 6 ms 5088 KB Output is correct
25 Correct 6 ms 5112 KB Output is correct
26 Correct 6 ms 5044 KB Output is correct
27 Correct 6 ms 5128 KB Output is correct
28 Correct 6 ms 5116 KB Output is correct
29 Correct 6 ms 5112 KB Output is correct
30 Correct 6 ms 5112 KB Output is correct
31 Correct 6 ms 5112 KB Output is correct
32 Correct 7 ms 5044 KB Output is correct
33 Correct 6 ms 5112 KB Output is correct
34 Correct 7 ms 5132 KB Output is correct
35 Correct 7 ms 5112 KB Output is correct
36 Correct 7 ms 5028 KB Output is correct
37 Correct 6 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5108 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5112 KB Output is correct
12 Correct 6 ms 5164 KB Output is correct
13 Correct 6 ms 5116 KB Output is correct
14 Correct 6 ms 5112 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 6 ms 5092 KB Output is correct
17 Correct 6 ms 5112 KB Output is correct
18 Correct 6 ms 5112 KB Output is correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 6 ms 5112 KB Output is correct
22 Correct 6 ms 5116 KB Output is correct
23 Correct 6 ms 5112 KB Output is correct
24 Correct 6 ms 5088 KB Output is correct
25 Correct 6 ms 5112 KB Output is correct
26 Correct 6 ms 5044 KB Output is correct
27 Correct 6 ms 5128 KB Output is correct
28 Correct 6 ms 5116 KB Output is correct
29 Correct 6 ms 5112 KB Output is correct
30 Correct 6 ms 5112 KB Output is correct
31 Correct 6 ms 5112 KB Output is correct
32 Correct 7 ms 5044 KB Output is correct
33 Correct 6 ms 5112 KB Output is correct
34 Correct 7 ms 5132 KB Output is correct
35 Correct 7 ms 5112 KB Output is correct
36 Correct 7 ms 5028 KB Output is correct
37 Correct 6 ms 5112 KB Output is correct
38 Correct 13 ms 5368 KB Output is correct
39 Correct 13 ms 5240 KB Output is correct
40 Correct 14 ms 5240 KB Output is correct
41 Correct 13 ms 5112 KB Output is correct
42 Correct 14 ms 5240 KB Output is correct
43 Correct 12 ms 5240 KB Output is correct
44 Correct 14 ms 5240 KB Output is correct
45 Correct 14 ms 5124 KB Output is correct
46 Correct 14 ms 5244 KB Output is correct
47 Correct 14 ms 5240 KB Output is correct
48 Correct 14 ms 5236 KB Output is correct
49 Correct 7 ms 5112 KB Output is correct
50 Correct 13 ms 5248 KB Output is correct
51 Correct 13 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5112 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5108 KB Output is correct
10 Correct 6 ms 5112 KB Output is correct
11 Correct 6 ms 5112 KB Output is correct
12 Correct 6 ms 5164 KB Output is correct
13 Correct 6 ms 5116 KB Output is correct
14 Correct 6 ms 5112 KB Output is correct
15 Correct 6 ms 5112 KB Output is correct
16 Correct 6 ms 5092 KB Output is correct
17 Correct 6 ms 5112 KB Output is correct
18 Correct 6 ms 5112 KB Output is correct
19 Correct 6 ms 5112 KB Output is correct
20 Correct 6 ms 5112 KB Output is correct
21 Correct 6 ms 5112 KB Output is correct
22 Correct 6 ms 5116 KB Output is correct
23 Correct 6 ms 5112 KB Output is correct
24 Correct 6 ms 5088 KB Output is correct
25 Correct 6 ms 5112 KB Output is correct
26 Correct 6 ms 5044 KB Output is correct
27 Correct 6 ms 5128 KB Output is correct
28 Correct 6 ms 5116 KB Output is correct
29 Correct 6 ms 5112 KB Output is correct
30 Correct 6 ms 5112 KB Output is correct
31 Correct 6 ms 5112 KB Output is correct
32 Correct 7 ms 5044 KB Output is correct
33 Correct 6 ms 5112 KB Output is correct
34 Correct 7 ms 5132 KB Output is correct
35 Correct 7 ms 5112 KB Output is correct
36 Correct 7 ms 5028 KB Output is correct
37 Correct 6 ms 5112 KB Output is correct
38 Correct 13 ms 5368 KB Output is correct
39 Correct 13 ms 5240 KB Output is correct
40 Correct 14 ms 5240 KB Output is correct
41 Correct 13 ms 5112 KB Output is correct
42 Correct 14 ms 5240 KB Output is correct
43 Correct 12 ms 5240 KB Output is correct
44 Correct 14 ms 5240 KB Output is correct
45 Correct 14 ms 5124 KB Output is correct
46 Correct 14 ms 5244 KB Output is correct
47 Correct 14 ms 5240 KB Output is correct
48 Correct 14 ms 5236 KB Output is correct
49 Correct 7 ms 5112 KB Output is correct
50 Correct 13 ms 5248 KB Output is correct
51 Correct 13 ms 5244 KB Output is correct
52 Execution timed out 2017 ms 15240 KB Time limit exceeded
53 Halted 0 ms 0 KB -