結果
問題 | No.3067 +10 Seconds Clock |
ユーザー |
|
提出日時 | 2025-03-21 21:37:24 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 1,414 ms |
コンパイル使用メモリ | 163,280 KB |
実行使用メモリ | 25,688 KB |
最終ジャッジ日時 | 2025-03-21 21:37:30 |
合計ジャッジ時間 | 3,165 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import std; void main () { int N, T; readln.read(N, T); auto t = readln.split.to!(int[]); int K = readln.chomp.to!int; auto x = readln.split.to!(int[]); // 貪欲に前からとってよい int tsum = sum(t); int need = (max(tsum + 1 - T, 0) + 10 - 1) / 10; int ans = need; bool[int] mp; foreach (v; x) mp[v] = true; bool ok = true; int cur = T; foreach (i; 0 .. N - 1) { if (cur - t[i] <= 0) ok = false; cur -= t[i]; if (i + 2 in mp) { if (0 < need) { need--; cur += 10; } } } if (ok) { writeln(ans); } else { writeln(-1); } } void read (T...) (string S, ref T args) { import std.conv : to; import std.array : split; auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }