답안 #958023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958023 2024-04-04T16:45:33 Z Soumya1 Long Distance Coach (JOI17_coach) C++17
71 / 100
2000 ms 16152 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
void testCase() {
  ll n, x, m, w, t;
  cin >> x >> n >> m >> w >> t;
  vector<ll> s(n + 2);
  for (int i = 1; i <= n; i++) cin >> s[i];
  s[n + 1] = x;
  vector<ll> c(m + 1), d(m + 1);
  for (int i = 1; i <= m; i++) cin >> d[i] >> c[i];
  vector<int> ord(m + 1);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int i, int j) { return d[i] < d[j]; });
  {
    auto cc = c, dd = d;
    for (int i = 0; i <= m; i++) {
      cc[i] = c[ord[i]];
      dd[i] = d[ord[i]];
    }
    c = cc, d = dd;
  }
  vector<ll> mn(m + 1, inf);
  for (int i = 1; i <= n + 1; i++) {
    ll x = s[i] % t;
    if (!x) continue;
    int j = lower_bound(d.begin(), d.end(), x) - d.begin() - 1;
    mn[j] = min(mn[j], s[i] / t);
  }
  vector<ll> sum(m + 1);
  for (int i = 1; i <= m; i++) sum[i] = sum[i - 1] + c[i];
  vector<ll> dp(m + 1, inf);
  dp[0] = (x / t + 1) * w;
  for (int i = 1; i <= m; i++) {
    dp[i] = dp[i - 1] + ((x - d[i]) / t + 1) * w;
    if (mn[i] == inf) continue;
    for (int j = 0; j < i; j++) {
      dp[i] = min(dp[i], dp[j] + (i - j) * mn[i] * w + sum[i] - sum[j]);
    }
  }
  cout << dp[m] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 456 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 456 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 3 ms 604 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 2 ms 600 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 3 ms 600 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 2 ms 520 KB Output is correct
50 Correct 3 ms 732 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 452 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 452 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 456 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 3 ms 348 KB Output is correct
40 Correct 3 ms 604 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 2 ms 600 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 3 ms 604 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 4 ms 348 KB Output is correct
47 Correct 3 ms 600 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 2 ms 520 KB Output is correct
50 Correct 3 ms 732 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Execution timed out 2049 ms 16152 KB Time limit exceeded
53 Halted 0 ms 0 KB -