結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー |
![]() |
提出日時 | 2019-11-29 22:18:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,484 bytes |
コンパイル時間 | 984 ms |
コンパイル使用メモリ | 96,732 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 05:45:22 |
合計ジャッジ時間 | 3,289 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<vector> #include<cmath> #include<algorithm> #include<map> #include<queue> #include<deque> #include<iomanip> #include<tuple> using namespace std; typedef long long int LL; typedef pair<int,int> P; typedef pair<LL,int> LP; const int INF=1<<30; const LL MAX=1e9+7; void array_show(int *array,int array_n,char middle=' '){ for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n')); } void array_show(LL *array,int array_n,char middle=' '){ for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n')); } void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n')); } void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){ if(vec_n==-1)vec_n=vec_s.size(); for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n')); } string sa; LL t[2005]; vector<LL> vs; int main(){ LL n,m,p; int i,j,k; LL a,b,c; LL s=0; cin>>n; cin>>sa; for(i=0;i<n;i++){ cin>>t[i]; } cin>>m; for(i=0;i<m;i++){ cin>>p; a=0,b=0,s=0; for(j=0,k=-1;j<n;j++){ if(a>p){ a-=t[j]; if(sa[j]=='E')b--; continue; } s=max(s,b); for(k++;k<n;k++){ a+=t[k]; if(sa[k]=='E')b++; if(a>p)break; s=max(s,b); } a-=t[j]; if(sa[j]=='E')b--; } vs.push_back(s); } for(i=0;i<m;i++){ cout<<vs[i]<<endl; } }