# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
24355 | 2017-06-05T17:01:31 Z | jiaqiyang | Long Distance Coach (JOI17_coach) | C++14 | 226 ms | 22844 KB |
#include <cstdio> #include <tuple> #include <vector> #include <algorithm> typedef long long i64; const int N = 200000 + 10; i64 t; int n, m, w; i64 s[N], d[N]; int c[N]; void init() { i64 x; scanf("%lld%d%d%d%lld", &x, &n, &m, &w, &t); for (int i = 1; i <= n; ++i) scanf("%lld", &s[i]); s[++n] = x; static std::pair<i64, int> info[N]; for (int i = 1; i <= m; ++i) scanf("%lld%d", &info[i].first, &info[i].second); std::sort(info + 1, info + m + 1); for (int i = 1; i <= m; ++i) std::tie(d[i], c[i]) = info[i]; } inline double slope(const std::pair<i64, i64> &a, const std::pair<i64, i64> &b) { return ((double)b.second - a.second) / (b.first - a.first); } int main() { init(); static std::vector<i64> pool[N]; for (int i = 1; i <= n; ++i) { i64 x = s[i] / t; int y = std::lower_bound(d + 1, d + m + 1, s[i] % t) - d - 1; pool[y].push_back(x); } static i64 f[N], sum[N]; for (int i = 1; i <= m; ++i) sum[i] = sum[i - 1] + c[i]; static std::pair<int, i64> q[N]; q[0] = {0, f[0] = (s[n] + t - 1) / t * w}; int tot = 0; for (int i = 1; i <= m; ++i) { f[i] = f[i - 1] + (s[n] - d[i] + t - 1) / t * w; for (auto k : pool[i]) { int l = 0, r = tot; while (l < r) { int mid = (l + r) >> 1; if (slope(q[mid], q[mid + 1]) < k) l = mid + 1; else r = mid; } f[i] = std::min(f[i], q[l].second - k * q[l].first + (i64)k * w * i + sum[i]); } std::pair<i64, i64> cur((i64)w * i, f[i] - sum[i]); while (tot && slope(q[tot - 1], q[tot]) >= slope(q[tot], cur)) --tot; q[++tot] = cur; } printf("%lld\n", f[m]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 19148 KB | Output is correct |
2 | Correct | 0 ms | 19148 KB | Output is correct |
3 | Correct | 0 ms | 19148 KB | Output is correct |
4 | Correct | 3 ms | 19148 KB | Output is correct |
5 | Correct | 3 ms | 19148 KB | Output is correct |
6 | Correct | 0 ms | 19148 KB | Output is correct |
7 | Correct | 3 ms | 19148 KB | Output is correct |
8 | Correct | 0 ms | 19148 KB | Output is correct |
9 | Correct | 0 ms | 19148 KB | Output is correct |
10 | Correct | 0 ms | 19148 KB | Output is correct |
11 | Correct | 0 ms | 19148 KB | Output is correct |
12 | Correct | 3 ms | 19148 KB | Output is correct |
13 | Correct | 0 ms | 19148 KB | Output is correct |
14 | Correct | 0 ms | 19148 KB | Output is correct |
15 | Correct | 0 ms | 19148 KB | Output is correct |
16 | Correct | 0 ms | 19148 KB | Output is correct |
17 | Correct | 0 ms | 19148 KB | Output is correct |
18 | Correct | 0 ms | 19148 KB | Output is correct |
19 | Correct | 0 ms | 19148 KB | Output is correct |
20 | Correct | 0 ms | 19148 KB | Output is correct |
21 | Correct | 0 ms | 19148 KB | Output is correct |
22 | Correct | 0 ms | 19148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 19148 KB | Output is correct |
2 | Correct | 0 ms | 19148 KB | Output is correct |
3 | Correct | 0 ms | 19148 KB | Output is correct |
4 | Correct | 3 ms | 19148 KB | Output is correct |
5 | Correct | 3 ms | 19148 KB | Output is correct |
6 | Correct | 0 ms | 19148 KB | Output is correct |
7 | Correct | 3 ms | 19148 KB | Output is correct |
8 | Correct | 0 ms | 19148 KB | Output is correct |
9 | Correct | 0 ms | 19148 KB | Output is correct |
10 | Correct | 0 ms | 19148 KB | Output is correct |
11 | Correct | 0 ms | 19148 KB | Output is correct |
12 | Correct | 3 ms | 19148 KB | Output is correct |
13 | Correct | 0 ms | 19148 KB | Output is correct |
14 | Correct | 0 ms | 19148 KB | Output is correct |
15 | Correct | 0 ms | 19148 KB | Output is correct |
16 | Correct | 0 ms | 19148 KB | Output is correct |
17 | Correct | 0 ms | 19148 KB | Output is correct |
18 | Correct | 0 ms | 19148 KB | Output is correct |
19 | Correct | 0 ms | 19148 KB | Output is correct |
20 | Correct | 0 ms | 19148 KB | Output is correct |
21 | Correct | 0 ms | 19148 KB | Output is correct |
22 | Correct | 0 ms | 19148 KB | Output is correct |
23 | Correct | 0 ms | 19148 KB | Output is correct |
24 | Correct | 0 ms | 19148 KB | Output is correct |
25 | Correct | 0 ms | 19148 KB | Output is correct |
26 | Correct | 0 ms | 19148 KB | Output is correct |
27 | Correct | 0 ms | 19148 KB | Output is correct |
28 | Correct | 3 ms | 19148 KB | Output is correct |
29 | Correct | 0 ms | 19148 KB | Output is correct |
30 | Correct | 0 ms | 19148 KB | Output is correct |
31 | Correct | 0 ms | 19148 KB | Output is correct |
32 | Correct | 3 ms | 19148 KB | Output is correct |
33 | Correct | 3 ms | 19148 KB | Output is correct |
34 | Correct | 0 ms | 19148 KB | Output is correct |
35 | Correct | 0 ms | 19148 KB | Output is correct |
36 | Correct | 3 ms | 19148 KB | Output is correct |
37 | Correct | 0 ms | 19148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 19148 KB | Output is correct |
2 | Correct | 0 ms | 19148 KB | Output is correct |
3 | Correct | 0 ms | 19148 KB | Output is correct |
4 | Correct | 3 ms | 19148 KB | Output is correct |
5 | Correct | 3 ms | 19148 KB | Output is correct |
6 | Correct | 0 ms | 19148 KB | Output is correct |
7 | Correct | 3 ms | 19148 KB | Output is correct |
8 | Correct | 0 ms | 19148 KB | Output is correct |
9 | Correct | 0 ms | 19148 KB | Output is correct |
10 | Correct | 0 ms | 19148 KB | Output is correct |
11 | Correct | 0 ms | 19148 KB | Output is correct |
12 | Correct | 3 ms | 19148 KB | Output is correct |
13 | Correct | 0 ms | 19148 KB | Output is correct |
14 | Correct | 0 ms | 19148 KB | Output is correct |
15 | Correct | 0 ms | 19148 KB | Output is correct |
16 | Correct | 0 ms | 19148 KB | Output is correct |
17 | Correct | 0 ms | 19148 KB | Output is correct |
18 | Correct | 0 ms | 19148 KB | Output is correct |
19 | Correct | 0 ms | 19148 KB | Output is correct |
20 | Correct | 0 ms | 19148 KB | Output is correct |
21 | Correct | 0 ms | 19148 KB | Output is correct |
22 | Correct | 0 ms | 19148 KB | Output is correct |
23 | Correct | 0 ms | 19148 KB | Output is correct |
24 | Correct | 0 ms | 19148 KB | Output is correct |
25 | Correct | 0 ms | 19148 KB | Output is correct |
26 | Correct | 0 ms | 19148 KB | Output is correct |
27 | Correct | 0 ms | 19148 KB | Output is correct |
28 | Correct | 3 ms | 19148 KB | Output is correct |
29 | Correct | 0 ms | 19148 KB | Output is correct |
30 | Correct | 0 ms | 19148 KB | Output is correct |
31 | Correct | 0 ms | 19148 KB | Output is correct |
32 | Correct | 3 ms | 19148 KB | Output is correct |
33 | Correct | 3 ms | 19148 KB | Output is correct |
34 | Correct | 0 ms | 19148 KB | Output is correct |
35 | Correct | 0 ms | 19148 KB | Output is correct |
36 | Correct | 3 ms | 19148 KB | Output is correct |
37 | Correct | 0 ms | 19148 KB | Output is correct |
38 | Correct | 3 ms | 19148 KB | Output is correct |
39 | Correct | 0 ms | 19280 KB | Output is correct |
40 | Correct | 0 ms | 19280 KB | Output is correct |
41 | Correct | 0 ms | 19148 KB | Output is correct |
42 | Correct | 0 ms | 19148 KB | Output is correct |
43 | Correct | 3 ms | 19148 KB | Output is correct |
44 | Correct | 0 ms | 19148 KB | Output is correct |
45 | Correct | 0 ms | 19148 KB | Output is correct |
46 | Correct | 0 ms | 19280 KB | Output is correct |
47 | Correct | 0 ms | 19280 KB | Output is correct |
48 | Correct | 3 ms | 19148 KB | Output is correct |
49 | Correct | 6 ms | 19148 KB | Output is correct |
50 | Correct | 0 ms | 19148 KB | Output is correct |
51 | Correct | 0 ms | 19148 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 19148 KB | Output is correct |
2 | Correct | 0 ms | 19148 KB | Output is correct |
3 | Correct | 0 ms | 19148 KB | Output is correct |
4 | Correct | 3 ms | 19148 KB | Output is correct |
5 | Correct | 3 ms | 19148 KB | Output is correct |
6 | Correct | 0 ms | 19148 KB | Output is correct |
7 | Correct | 3 ms | 19148 KB | Output is correct |
8 | Correct | 0 ms | 19148 KB | Output is correct |
9 | Correct | 0 ms | 19148 KB | Output is correct |
10 | Correct | 0 ms | 19148 KB | Output is correct |
11 | Correct | 0 ms | 19148 KB | Output is correct |
12 | Correct | 3 ms | 19148 KB | Output is correct |
13 | Correct | 0 ms | 19148 KB | Output is correct |
14 | Correct | 0 ms | 19148 KB | Output is correct |
15 | Correct | 0 ms | 19148 KB | Output is correct |
16 | Correct | 0 ms | 19148 KB | Output is correct |
17 | Correct | 0 ms | 19148 KB | Output is correct |
18 | Correct | 0 ms | 19148 KB | Output is correct |
19 | Correct | 0 ms | 19148 KB | Output is correct |
20 | Correct | 0 ms | 19148 KB | Output is correct |
21 | Correct | 0 ms | 19148 KB | Output is correct |
22 | Correct | 0 ms | 19148 KB | Output is correct |
23 | Correct | 0 ms | 19148 KB | Output is correct |
24 | Correct | 0 ms | 19148 KB | Output is correct |
25 | Correct | 0 ms | 19148 KB | Output is correct |
26 | Correct | 0 ms | 19148 KB | Output is correct |
27 | Correct | 0 ms | 19148 KB | Output is correct |
28 | Correct | 3 ms | 19148 KB | Output is correct |
29 | Correct | 0 ms | 19148 KB | Output is correct |
30 | Correct | 0 ms | 19148 KB | Output is correct |
31 | Correct | 0 ms | 19148 KB | Output is correct |
32 | Correct | 3 ms | 19148 KB | Output is correct |
33 | Correct | 3 ms | 19148 KB | Output is correct |
34 | Correct | 0 ms | 19148 KB | Output is correct |
35 | Correct | 0 ms | 19148 KB | Output is correct |
36 | Correct | 3 ms | 19148 KB | Output is correct |
37 | Correct | 0 ms | 19148 KB | Output is correct |
38 | Correct | 3 ms | 19148 KB | Output is correct |
39 | Correct | 0 ms | 19280 KB | Output is correct |
40 | Correct | 0 ms | 19280 KB | Output is correct |
41 | Correct | 0 ms | 19148 KB | Output is correct |
42 | Correct | 0 ms | 19148 KB | Output is correct |
43 | Correct | 3 ms | 19148 KB | Output is correct |
44 | Correct | 0 ms | 19148 KB | Output is correct |
45 | Correct | 0 ms | 19148 KB | Output is correct |
46 | Correct | 0 ms | 19280 KB | Output is correct |
47 | Correct | 0 ms | 19280 KB | Output is correct |
48 | Correct | 3 ms | 19148 KB | Output is correct |
49 | Correct | 6 ms | 19148 KB | Output is correct |
50 | Correct | 0 ms | 19148 KB | Output is correct |
51 | Correct | 0 ms | 19148 KB | Output is correct |
52 | Incorrect | 226 ms | 22844 KB | Output isn't correct |
53 | Halted | 0 ms | 0 KB | - |