답안 #751808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
751808 2023-06-01T13:38:55 Z tch1cherin Semiexpress (JOI17_semiexpress) C++17
100 / 100
1 ms 464 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve() {
  int N, M, K;
  cin >> N >> M >> K;
  int A, B, C;
  cin >> A >> B >> C;
  long long T;
  cin >> T;
  vector<int> S(M);
  for (auto &v : S) {
    cin >> v;
    v--;
  }
  priority_queue<tuple<int, long long, int, int>> s;
  long long ans = -1;
  auto Place = [&](long long time, int position, int j) {
    long long pos = position + (T - time) / A + 1;
    bool bad = false;
    if (pos >= N) {
      pos = N;
      bad = true;
    }
    if (j + 1 < M && S[j + 1] <= pos) {
      pos = S[j + 1];
      bad = true;
    }
    ans += pos - position;
    long long new_time = 1ll * S[j] * B + 1ll * (pos - S[j]) * C;
    if (!bad && new_time <= T) {
      int cnt = min(S[j + 1] - pos, (T - new_time) / A);
      s.emplace(cnt, new_time, pos, j); 
    } 
  };
  for (int i = 0; i < M; i++) {
    long long time = 1ll * S[i] * B;
    int position = S[i];
    int j = i;
    if (time <= T) {
      Place(time, position, j);
    }
  }
  for (int i = 0; i < K - M && !s.empty(); i++) {
    auto [cnt, time, position, j] = s.top();
    s.pop();
    if (time > T) {
      break;
    }
    Place(time, position, j);
  }
  cout << ans << "\n";
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 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 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 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 332 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 464 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