結果
| 問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-30 15:54:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,298 bytes |
| コンパイル時間 | 825 ms |
| コンパイル使用メモリ | 86,632 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 01:21:25 |
| 合計ジャッジ時間 | 2,594 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 56 WA * 2 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define endl "\n"
constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(10);
int N, Q;
vector<int> A;
vector<int> temp, con;
string S;
cin>>N>>S;
A.resize(N+1);
temp.resize(N, INF);
con.resize(N+1);
for(int i = 0; i < N; i++){
cin>>A[i+1];
if(S[i] == 'E') con[i+1]++;
con[i+1] += con[i];
A[i+1] += A[i];
// cout<<"A "<<i<<" "<<A[i+1]<<endl;
}
for(int i = 0; i < N; i++){
for(int j = i + 1; j <= N; j++){
temp[con[j]-con[i]] = min(temp[con[j]-con[i]], A[j] - A[i]);
// cout<<"i = "<<i<<" j = "<<j<<" A "<<A[j]<<" - "<<A[i]<<endl;
}
}
temp[0] = 0;
for(int i = N-1; i > 0; i--){
// cout<<"i "<<i-1<<" "<<temp[i-1]<<endl;
temp[i-1] = min(temp[i-1], temp[i]);
// cout<<"i "<<i-1<<" "<<temp[i-1]<<endl;
}
cin>>Q;
for(int i = 0; i < Q; i++){
int K, ans = 0;
cin>>K;
ans = upper_bound(temp.begin(), temp.end(), K) - temp.begin();
cout<<ans-1<<endl;
}
return 0;
}