結果
問題 |
No.3067 +10 Seconds Clock
|
ユーザー |
|
提出日時 | 2025-03-21 22:28:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,218 bytes |
コンパイル時間 | 2,372 ms |
コンパイル使用メモリ | 202,652 KB |
実行使用メモリ | 13,896 KB |
最終ジャッジ日時 | 2025-03-21 22:29:36 |
合計ジャッジ時間 | 3,576 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 5 WA * 18 |
ソースコード
#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; unordered_set<int> clockLocations; for (int i = 0; i < K; i++) { int x; cin >> x; clockLocations.insert(x - 1); // Store as 0-based index } deque<int> dq; // Deque to store available clocks efficiently int timeLeft = T, clocksUsed = 0; for (int i = 0; i < N - 1; i++) { timeLeft -= t[i]; // Move to the next location if (timeLeft < 0) { // If time runs out before reaching cout << "-1\n"; return 0; } if (clockLocations.count(i)) dq.push_back(10); // Add +10 clock if available while (!dq.empty() && timeLeft < 0) { // Use clocks only when absolutely necessary timeLeft += dq.front(); dq.pop_front(); clocksUsed++; } if (timeLeft < 0) { // If we still can't proceed, fail cout << "-1\n"; return 0; } } cout << clocksUsed << "\n"; return 0; }