Submission #869178

# Submission time Handle Problem Language Result Execution time Memory
869178 2023-11-03T11:50:39 Z tvladm2009 Semiexpress (JOI17_semiexpress) C++17
100 / 100
26 ms 33992 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N = 3000 + 7;
ll stat[N];
ll n, m, k, a, b, c, t;

int main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif // ONPC
#ifndef ONPC
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif // ONPC

  cin >> n >> m >> k >> a >> b >> c >> t;
  for (int i = 0; i < m; i++) {
    cin >> stat[i];
  }
  ll sol = 0;
  if ((n - 1) * b <= t) {
    sol++;
  }
  priority_queue<ll> pq;
  for (int i = 0; i < m - 1; i++) {
    ll tt = (stat[i] - 1) * b;
    if (tt > t) break;
    ll add = (t - tt) / a;
    ll range = min(stat[i + 1] - 1, stat[i] + add);
    sol += range - stat[i] + (i > 0);
    for (int j = 0; j < k && range < stat[i + 1] - 1; j++) {
      ll tmp = tt + (range + 1 - stat[i]) * c;
      if (tmp > t) break;
      ll qq = (t - tmp) / a;
      ll new_range = min(stat[i + 1] - 1, range + qq + 1);
      pq.push(new_range - range);
      range = new_range;
    }
  }
  for (int i = 1; i <= k - m; i++) {
    if (!pq.empty()) {
      sol += pq.top();
      pq.pop();
    }
  }
  cout << sol << "\n";
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 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 348 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 460 KB Output is correct
15 Correct 1 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 0 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 348 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 460 KB Output is correct
15 Correct 1 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 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 2520 KB Output is correct
22 Correct 2 ms 1500 KB Output is correct
23 Correct 8 ms 8796 KB Output is correct
24 Correct 7 ms 5964 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 21 ms 18124 KB Output is correct
28 Correct 26 ms 33992 KB Output is correct
29 Correct 6 ms 5584 KB Output is correct
30 Correct 3 ms 2520 KB Output is correct