結果
| 問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
| コンテスト | |
| ユーザー |
shop_one
|
| 提出日時 | 2019-11-29 22:30:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 698 ms |
| コンパイル使用メモリ | 67,088 KB |
| 実行使用メモリ | 6,812 KB |
| 最終ジャッジ日時 | 2024-09-14 05:49:55 |
| 合計ジャッジ時間 | 2,754 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 57 WA * 1 |
ソースコード
// I SELL YOU...!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
ll n,q,ans,k,le,ri,v;
string s;
cin >> n >> s;
ll a[n];
ll cnt[n+1];
fill(cnt,cnt+n+1,0);
for(int i=0;i<n;i++){
cin >> a[i];
if(s[i]=='E'){
cnt[i]++;
}
if(i!=0)cnt[i]+=cnt[i-1];
}
cin >> q;
ll tmp;
for(int i=0;i<q;i++){
cin >> k;
ans = 0;
le=0;
ri=0;
v=0;
while(ri<n){
if(v<=k&&ri!=0){
tmp = cnt[ri-1];
if(le!=0) tmp-=cnt[le-1];
// cout << le<<" "<<ri<<" "<<tmp<<endl;
ans = max(ans,tmp);
}
if(v<=k||ri==le){
v += a[ri++];
}else{
v -= a[le++];
}
}
if(v<=k){
tmp = cnt[ri-1];
if(le!=0) tmp-=cnt[le-1];
ans = max(tmp,ans);
}
cout << ans << endl;
}
}
shop_one