結果
問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
ユーザー |
|
提出日時 | 2019-11-29 22:15:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,047 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 86,932 KB |
実行使用メモリ | 124,416 KB |
最終ジャッジ日時 | 2024-11-20 23:26:11 |
合計ジャッジ時間 | 53,295 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 51 TLE * 7 |
ソースコード
#include<iostream> #include<vector> #include<map> using namespace std; typedef long long ll; int main(){ int n; string s; cin >> n >> s; vector<int> e(n, 0); for(int i = 0; i < n; i++){ if(i) e[i] += e[i-1]; e[i] += s[i]=='E'; } vector<ll> sum(n); for(int i = 0; i < n; i++){ cin >> sum[i]; if(i) sum[i] += sum[i-1]; } map<ll,int> m; for(int i = 0; i < n; i++){ for(int j = i; j < n; j++){ int tmp = e[j] - (i==0 ? 0 : e[i-1]); if(tmp == 0) continue; ll p = sum[j] - (i==0 ? 0 : sum[i-1]); if(m.count(p)) m[p] = max(m[p], tmp); else m[p] = tmp; } } auto bef = m.begin(); for(auto it = ++m.begin(); it != m.end(); it++){ m[it->first] = max(it->second, bef->second); bef = it; } m[0] = 0; int q; cin >> q; while(q-- > 0){ ll k; cin >> k; cout << (--m.upper_bound(k))->second << endl; } return 0; }