結果
問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
ユーザー |
|
提出日時 | 2019-11-29 22:28:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 982 bytes |
コンパイル時間 | 1,014 ms |
コンパイル使用メモリ | 93,232 KB |
最終ジャッジ日時 | 2025-01-08 06:05:29 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <utility> #include <string> #include <cstdlib> #include <queue> #include <map> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; vector<ll> a(n); for (auto &x: a) cin >> x; int q; cin >> q; vector<ll> k(q); for (auto &x: k) cin >> x; vector<int> ans(q); for (int i = 0; i < q; i++) { ll power = k[i]; int killed = 0; int p1 = 0, p2 = 0; while (p2 <= n) { if (power >= 0) { if (p2 >= n) break; power -= a[p2]; if (s[p2] == 'E') killed++; p2++; } else { power += a[p1]; if (s[p1] == 'E') killed--; p1++; } if (power >= 0) ans[i] = max(ans[i], killed); } } for (auto &x: ans) cout << x << endl; return 0; }