結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー |
![]() |
提出日時 | 2019-11-29 22:35:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 807 bytes |
コンパイル時間 | 687 ms |
コンパイル使用メモリ | 72,572 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-14 05:50:34 |
合計ジャッジ時間 | 2,851 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 57 WA * 1 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; using ll = long long int; using P = pair<ll,ll>; constexpr ll INF = 1LL<<50; int main() { int n; string s; cin >> n >> s; vector<ll> a(n+1), cnt(n+1); for(int i=0;i<n;i++){ cin >> a[i+1]; a[i+1] += a[i]; if(s[i] == 'E') cnt[i+1]++; cnt[i+1] += cnt[i]; } int q; cin >> q; for(int i=0;i<q;i++){ ll k, ans = 0; cin >> k; int l=0, r=0; while(r<n){ while(l<=r && a[r]-a[l] > k){ l++; } while(r<=n && a[r]-a[l] <= k){ ans = max(ans, cnt[r]-cnt[l]); r++; } } cout << ans << endl; } return 0; }