結果
| 問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
| コンテスト | |
| ユーザー |
tanimani364
|
| 提出日時 | 2019-11-30 17:10:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,408 bytes |
| コンパイル時間 | 1,311 ms |
| コンパイル使用メモリ | 120,244 KB |
| 最終ジャッジ日時 | 2025-01-08 06:28:52 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 58 |
ソースコード
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
void solve(){
int n;
cin>>n;
string s;
cin>>s;
vector<ll>ene(n+1);
rep(i,n)ene[i+1]=ene[i]+(s[i]=='E');
vector<int>a(n);
rep(i,n)cin>>a[i];
int q;
cin>>q;
while(q--){
ll k;
cin>>k;
ll r=0;
ll sum=0;
ll maxv=0;
for(ll l=0;l<n;++l){
while(r<n&&sum+a[r]<=k){
sum+=a[r++];
}
chmax(maxv,ene[r]-ene[l]);
if(l==r)++r;
else sum-=a[l];
}
cout<<maxv<<"\n";
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout<<fixed<<setprecision(15);
solve();
return 0;
}
tanimani364