답안 #654295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654295 2022-10-30T22:17:21 Z lunchbox1 Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 340 KB
/*
 Semiexpress
 https://oj.uz/problem/view/JOI17_semiexpress
*/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
 
int main() {
 ios::sync_with_stdio(0), cin.tie(0);
 int n, m, k; cin >> n >> m >> k;
 LL a, b, c; cin >> a >> b >> c;
 long long t; cin >> t;
 vector<LL> s(m), p(m - 1); for (LL& x : s) cin >> x;
 priority_queue<pair<LL, int>> pq;
 LL ans = b * (n - 1) <= t ? 0 : -1;
 for (int i = 0; i < m - 1; i++) {
  if (b * (s[i] - 1) > t) continue;
  LL u = min(s[i + 1] - 1, s[i] + (t - b * (s[i] - 1)) / a);
  ans += u - s[i] + 1;
  p[i] = u + 1;
  if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t)
   pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i});
 }
 for (int it = 0; it < k - m; it++) {
  if (pq.empty()) break;
  auto [v, i] = pq.top(); pq.pop();
  ans += v, p[i] += v;
  if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t)
   pq.push({min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a) - p[i] + 1, i});
 }
 cout << ans << '\n';
 return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct