답안 #563846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563846 2022-05-18T07:27:47 Z amunduzbaev Long Distance Coach (JOI17_coach) C++17
71 / 100
2000 ms 11252 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ar array
#define int long long

const int inf = 1e18;
const int N = 2e5 + 5;
int s[N], d[N], c[N];

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int x, n, m, w, t; cin>>x>>n>>m>>w>>t;
	for(int i=0;i<n;i++) cin>>s[i];
	vector<int> p(m), d_(m), mn(m, x + 1);
	int tot = 0;
	for(int i=0;i<m;i++){
		cin>>d[i]>>c[i];
		p[i] = i;
		tot += (x / t + (d[i] < x % t)) * w;
	}
	
	tot += (x / t + 1) * w;
	
	sort(p.begin(), p.end(), [&](int i, int j){
		return d[i] < d[j];
	});
	for(int i=0;i<m;i++) d_[i] = d[p[i]];
	s[n] = x;
	for(int i=0;i<=n;i++){
		int j = upper_bound(d_.begin(), d_.end(), s[i] % t) - d_.begin();
		if(j){ --j;
			//~ assert(d_[j] != s[i] % t);
			mn[j] = min(mn[j], s[i]);
		}
	}
	
	vector<int> dp(m);
	for(int i=0;i<m;i++){
		if(i) dp[i] = dp[i-1];
		if(mn[i] > x) continue;
		int M = mn[i], cur = 0;
		for(int j=i;~j;j--){
			//~ M = min(M, mn[j]);
			cur = cur - (x / t + (d_[j] < x % t) - M / t) * w + c[p[j]];
			dp[i] = min(dp[i], (j ? dp[j-1] : 0) + cur);
		}
	}
	
	//~ cout<<dp[m-1]<<"\n";
	cout<<tot + dp[m-1]<<"\n";
}

/*

166833333456456789
333333209997456789

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 15 ms 340 KB Output is correct
39 Correct 30 ms 340 KB Output is correct
40 Correct 60 ms 428 KB Output is correct
41 Correct 16 ms 452 KB Output is correct
42 Correct 16 ms 452 KB Output is correct
43 Correct 14 ms 340 KB Output is correct
44 Correct 22 ms 448 KB Output is correct
45 Correct 17 ms 452 KB Output is correct
46 Correct 29 ms 444 KB Output is correct
47 Correct 33 ms 340 KB Output is correct
48 Correct 18 ms 448 KB Output is correct
49 Correct 17 ms 448 KB Output is correct
50 Correct 15 ms 456 KB Output is correct
51 Correct 16 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 15 ms 340 KB Output is correct
39 Correct 30 ms 340 KB Output is correct
40 Correct 60 ms 428 KB Output is correct
41 Correct 16 ms 452 KB Output is correct
42 Correct 16 ms 452 KB Output is correct
43 Correct 14 ms 340 KB Output is correct
44 Correct 22 ms 448 KB Output is correct
45 Correct 17 ms 452 KB Output is correct
46 Correct 29 ms 444 KB Output is correct
47 Correct 33 ms 340 KB Output is correct
48 Correct 18 ms 448 KB Output is correct
49 Correct 17 ms 448 KB Output is correct
50 Correct 15 ms 456 KB Output is correct
51 Correct 16 ms 444 KB Output is correct
52 Execution timed out 2045 ms 11252 KB Time limit exceeded
53 Halted 0 ms 0 KB -