結果

問題 No.3067 +10 Seconds Clock
ユーザー keisuke6
提出日時 2025-03-21 21:30:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 199,644 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2025-03-21 21:30:57
合計ジャッジ時間 8,299 ms
ジャッジサーバーID
(参考情報)
judge6 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N,T;
    cin>>N>>T;
    vector<int> A(N-1);
    int st = 0;
    for(int i=0;i<N-1;i++){
    	cin>>A[i];
    	st += A[i];
    }
    if(st < T){
    	cout<<0<<endl;
    	return 0;
    }
    int M;
    cin>>M;
    vector<int> S(M);
    for(int i=0;i<M;i++){
    	cin>>S[i];
    	S[i]-=2;
    }
    int ac = M+1, wa = 0;
    while(ac-wa > 1){
    	int md = (ac+wa)/2;
    	set<int> s;
    	for(int i=0;i<md;i++) s.insert(S[i]);
    	int now = T;
    	bool ok = true;
    	for(int i=0;i<N-1;i++){
    		now -= A[i];
    		if(now <= 0) ok = false;
    		if(s.count(i)) now += 10;
    	}
    	if(ok) ac = md;
    	else wa = md;
    }
    cout<<(ac > M ? -1 : ac)<<endl;
}
0