結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
![]() |
提出日時 | 2020-08-22 15:56:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,677 bytes |
コンパイル時間 | 1,082 ms |
コンパイル使用メモリ | 97,448 KB |
実行使用メモリ | 5,344 KB |
最終ジャッジ日時 | 2024-10-15 10:05:09 |
合計ジャッジ時間 | 3,150 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 1 |
ソースコード
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<queue> #include<deque> #include<cmath> #include<map> #include<unordered_map> #include<set> #include<cstring> #include<iomanip> //cout << fixed << setprecision(15) << x << endl; using namespace std; typedef long long ll; const ll INF = 1e9 + 8; const ll MOD = 1e9 + 7; const ll LLINF = 1e18; #define Pint pair<int, int> #define rng(i, a, b) for(int i = int(a); i < int(b); i++) #define rnr(i, a, b) for(int i = int(a); i >= int(b); i--) #define rep(i, b) rng(i, 0, b) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() /* -- template -- */ int main() { int n, m; cin >> n >> m; ll a[n]; rep(i, n) cin >> a[i]; string s; cin >> s; int l = 0, r = n - 1; int now = 0, maxr = 0, minl = 0, peni = 0; for(char c : s) { if(c == 'L') { if(peni > 0) --peni; --now; if(l < n - 1) { if(now < minl) { a[l + 1] += a[l]; a[l] = 0; ++l; minl = now; } } } else if(c == 'R') { if(peni < n - 1) ++peni; ++now; if(r > 0) { if(now > maxr) { a[r - 1] += a[r]; a[r] = 0; --r; maxr = now; } } } } int j = 0; rep(i, peni) cout << 0 << ' '; rng(i, peni, n) { if(l + j >= n) { cout << 0 << ' '; } else { cout << a[l + j] << ' '; } ++j; } }