結果
問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
ユーザー |
![]() |
提出日時 | 2019-12-30 00:17:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 665 ms |
コンパイル使用メモリ | 72,520 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 21:47:17 |
合計ジャッジ時間 | 3,445 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
#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; }