結果
問題 | No.3067 +10 Seconds Clock |
ユーザー |
|
提出日時 | 2025-03-21 22:45:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,191 bytes |
コンパイル時間 | 1,993 ms |
コンパイル使用メモリ | 200,996 KB |
実行使用メモリ | 7,324 KB |
最終ジャッジ日時 | 2025-03-21 22:45:24 |
合計ジャッジ時間 | 3,300 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, T, K; cin >> N >> T; vector<int> t(N - 1); for (int i = 0; i < N - 1; i++) cin >> t[i]; cin >> K; vector<int> clocks(K); for (int i = 0; i < K; i++) { cin >> clocks[i]; clocks[i]--; } sort(clocks.begin(), clocks.end()); priority_queue<int, vector<int>, greater<int>> pq; int timeLeft = T, clocksUsed = 0, clockIndex = 0; for (int i = 0; i < N - 1; i++) { timeLeft -= t[i]; while (timeLeft < 0 && !pq.empty()) { timeLeft += pq.top(); pq.pop(); clocksUsed++; } if (timeLeft < 0) { cout << "-1\n"; return 0; } while (clockIndex < K && clocks[clockIndex] == i) { pq.push(10); clockIndex++; } } if (timeLeft == 0 && !pq.empty()) { timeLeft += pq.top(); pq.pop(); clocksUsed++; } if (timeLeft <= 0) { cout << "-1\n"; } else { cout << clocksUsed << "\n"; } return 0; }