답안 #113109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
113109 2019-05-23T17:43:35 Z Bruteforceman Long Distance Coach (JOI17_coach) C++11
71 / 100
2000 ms 17548 KB
#include "bits/stdc++.h"
using namespace std;
long long s[200010];
long long d[200010];
long long c[200010];
int N, M;
long long X, W, T;
typedef pair <long long, int> pii;
vector <pii> v;
long long dp[200010];

int solve(int mask) {
	for(int i = 0; i < v.size(); i++) {
		if(v[i].second < 0) {

		}
	}
}


int main(int argc, char const *argv[])
{
	scanf("%lld %d %d %lld %lld", &X, &N, &M, &W, &T);
	for(int i = 1; i <= N; i++) {
		scanf("%lld", &s[i]);
	}
	s[++N] = X;
	for(int i = 1; i <= N; i++) {
		v.push_back(pii(s[i] % T, i));
	}  
	for(int i = 1; i <= M; i++) {
		scanf("%lld %lld", &d[i], &c[i]);
		v.push_back(pii(d[i], -i));
	}
	sort(v.begin(), v.end());

	long long ans = (X / T) + 1;
	for(int i = 1; i <= M; i++) {
		ans += 1 + ((X - d[i]) / T);
	}
	ans *= W;

	dp[0] = 0;
	for(int i = 1; i < v.size(); i++) {
		if(v[i].second < 0) {
			dp[i] = dp[i - 1];
		} else {
			long long var = s[v[i].second] / T;
			long long cost = 0;
			for(int cur = i; cur >= 0; cur--) {
				if(v[cur].second < 0) {
					int id = -v[cur].second;
					cost += c[id];
					cost -= W * (1 + ((X - d[id]) / T));
					cost += W * var;
				}
				if(cur > 0) {
					dp[i] = min(dp[i], dp[cur - 1] + cost);
				} else {
					dp[i] = min(dp[i], cost);
				}
			}
		}
	}
	ans += dp[v.size() - 1];
	printf("%lld\n", ans);
	return 0;
}

Compilation message

coach.cpp: In function 'int solve(int)':
coach.cpp:13:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < v.size(); i++) {
                 ~~^~~~~~~~~~
coach.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
coach.cpp: In function 'int main(int, const char**)':
coach.cpp:44:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i < v.size(); i++) {
                 ~~^~~~~~~~~~
coach.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %d %d %lld %lld", &X, &N, &M, &W, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &s[i]);
   ~~~~~^~~~~~~~~~~~~~~
coach.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &d[i], &c[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 356 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 356 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 356 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 36 ms 632 KB Output is correct
39 Correct 32 ms 632 KB Output is correct
40 Correct 32 ms 644 KB Output is correct
41 Correct 37 ms 512 KB Output is correct
42 Correct 36 ms 504 KB Output is correct
43 Correct 27 ms 512 KB Output is correct
44 Correct 54 ms 632 KB Output is correct
45 Correct 37 ms 628 KB Output is correct
46 Correct 31 ms 512 KB Output is correct
47 Correct 33 ms 668 KB Output is correct
48 Correct 37 ms 760 KB Output is correct
49 Correct 36 ms 640 KB Output is correct
50 Correct 48 ms 632 KB Output is correct
51 Correct 37 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 356 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 36 ms 632 KB Output is correct
39 Correct 32 ms 632 KB Output is correct
40 Correct 32 ms 644 KB Output is correct
41 Correct 37 ms 512 KB Output is correct
42 Correct 36 ms 504 KB Output is correct
43 Correct 27 ms 512 KB Output is correct
44 Correct 54 ms 632 KB Output is correct
45 Correct 37 ms 628 KB Output is correct
46 Correct 31 ms 512 KB Output is correct
47 Correct 33 ms 668 KB Output is correct
48 Correct 37 ms 760 KB Output is correct
49 Correct 36 ms 640 KB Output is correct
50 Correct 48 ms 632 KB Output is correct
51 Correct 37 ms 512 KB Output is correct
52 Execution timed out 2044 ms 17548 KB Time limit exceeded
53 Halted 0 ms 0 KB -