結果
問題 | No.1433 Two color sequence |
ユーザー |
![]() |
提出日時 | 2021-03-19 22:24:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 98 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 1,849 ms |
コンパイル使用メモリ | 195,824 KB |
最終ジャッジ日時 | 2025-01-19 18:47:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include<bits/stdc++.h>using namespace std;const ll INF=1e18+7;int main(){int n;string s;cin>>n>>s;vector<ll> A(n+1);A[0]=0;rep(i,n){ll x;cin>>x;if(s[i]=='R') A[i+1]=x;else A[i+1]=-x;}ll ma=-INF,mi=INF,tmp=0;rep(i,n+1){tmp+=A[i];ma=max(ma,tmp);mi=min(mi,tmp);}cout<<abs(ma-mi)<<endl;return 0;}