結果
問題 | No.3067 +10 Seconds Clock |
ユーザー |
|
提出日時 | 2025-03-21 21:46:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 961 bytes |
コンパイル時間 | 4,479 ms |
コンパイル使用メモリ | 250,152 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-21 21:46:51 |
合計ジャッジ時間 | 5,940 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template <typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template <typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct IOST { IOST() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); } } IOST; int main(){ int n,t; cin>>n>>t; vector<int> a(n-1); rep(i,0,n-1) cin>>a[i]; int k; cin>>k; vector<int> x(k); rep(i,0,k) cin>>x[i],x[i]--; auto check=[&](int mx){ int ct=t; int cx=0; rep(i,0,n-1){ if(ct<=0) break; if(cx<mx&&i==x[cx]){ cx++; ct+=10; } ct-=a[i]; } return ct<=0; }; if(check(k)){ cout<<"-1\n"; return 0; } int up=k; int dw=-1; while(up-dw>1){ int md=(up+dw)/2; if(check(md)) dw=md; else up=md; } cout<<up<<"\n"; }