結果
| 問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
| コンテスト | |
| ユーザー |
jjjjjjjtgpptmjj
|
| 提出日時 | 2019-11-29 22:09:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 1,733 bytes |
| コンパイル時間 | 1,251 ms |
| コンパイル使用メモリ | 161,420 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 05:44:02 |
| 合計ジャッジ時間 | 3,293 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 58 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
/*------------------------------------/
for library*/
/*------------------------------------*/
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int N;
string S;
cin>>N>>S;
vector<int> A(N);
rep(i,N)cin>>A[i];
int Q;
cin>>Q;
vector<int> K(Q);
rep(i,Q)cin>>K[i];
auto solve = [&](int k){
int res = 0;
int r = 0;
int sum = 0;
int cnt = 0;
for(int l = 0;l < N;l++){
while(r < N&&sum+A[r] <= k){
sum += A[r];
if(S[r] == 'E')cnt++;
r++;
}
chmax(res, cnt);
if(l == r){
r++;
}
else{
sum -= A[l];
if(S[l] == 'E')cnt--;
}
}
return res;
};
rep(i,Q){
cout<<solve(K[i])<<endl;;
}
}
jjjjjjjtgpptmjj