Submission #127857

# Submission time Handle Problem Language Result Execution time Memory
127857 2019-07-10T07:18:00 Z 조승현(#3114) Long Distance Coach (JOI17_coach) C++14
71 / 100
2000 ms 10344 KB
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define N_ 201000
using namespace std;
#define pii pair<int,int>

long long X[N_], D[N_];
int n, m;
long long cost, T;

struct point {
	long long x, c;
	bool operator <(const point &p)const {
		return x < p.x;
	}
}w[N_];

long long First[N_], Z[N_], INF = 4e18;

int main() {
	int i, j;
	scanf("%lld%d%d%lld%lld", &X[0], &m, &n, &cost, &T);
	for (i = 1; i <= m; i++) {
		scanf("%lld", &X[i]);
	}
	X[m + 1] = 0;
	sort(X, X + m + 2);
	m++;
	for (i = 1; i <= n; i++) {
		scanf("%lld%lld", &w[i].x, &w[i].c);
	}
	sort(w + 1, w + n + 1);
	for (i = 1; i <= n; i++)Z[i] = w[i].x;
	D[n + 1] = 0;
	for (i = 0; i <= n; i++)D[i] = INF;
	for (i = 0; i <= n; i++)First[i] = INF;
	for (i = 1; i <= m; i++) {
		int pv = lower_bound(Z, Z + n + 1, X[i] % T) - Z;
		First[pv % (n + 1)] = min(First[pv % (n + 1)], X[i]);
	}
	for (i = n + 1; i >= 1; i--) {
		long long f = INF;
		long long s = 0;
		for (j = i - 1; j >= 0; j--) {
			D[j] = min(D[j], D[i] + s + ((X[m] - w[j].x) / T + 1)*cost);
			f = min(f, First[(j + 1) % (n + 1)]);
			if (f >= INF)break;
			s += (f/T - w[j].x / T)*cost;
			s += w[j].c;
		}
	}
	printf("%lld\n", D[0]);
}

Compilation message

coach.cpp: In function 'int main()':
coach.cpp:24: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[0], &m, &n, &cost, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
coach.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &X[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", &w[i].x, &w[i].c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 352 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 352 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 380 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 352 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 380 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 48 ms 548 KB Output is correct
39 Correct 93 ms 508 KB Output is correct
40 Correct 94 ms 528 KB Output is correct
41 Correct 48 ms 604 KB Output is correct
42 Correct 49 ms 540 KB Output is correct
43 Correct 44 ms 376 KB Output is correct
44 Correct 50 ms 552 KB Output is correct
45 Correct 47 ms 604 KB Output is correct
46 Correct 92 ms 492 KB Output is correct
47 Correct 93 ms 508 KB Output is correct
48 Correct 47 ms 504 KB Output is correct
49 Correct 47 ms 632 KB Output is correct
50 Correct 48 ms 504 KB Output is correct
51 Correct 51 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 352 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 352 KB Output is correct
20 Correct 2 ms 380 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 380 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 48 ms 548 KB Output is correct
39 Correct 93 ms 508 KB Output is correct
40 Correct 94 ms 528 KB Output is correct
41 Correct 48 ms 604 KB Output is correct
42 Correct 49 ms 540 KB Output is correct
43 Correct 44 ms 376 KB Output is correct
44 Correct 50 ms 552 KB Output is correct
45 Correct 47 ms 604 KB Output is correct
46 Correct 92 ms 492 KB Output is correct
47 Correct 93 ms 508 KB Output is correct
48 Correct 47 ms 504 KB Output is correct
49 Correct 47 ms 632 KB Output is correct
50 Correct 48 ms 504 KB Output is correct
51 Correct 51 ms 504 KB Output is correct
52 Execution timed out 2045 ms 10344 KB Time limit exceeded
53 Halted 0 ms 0 KB -