結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
|
提出日時 | 2020-05-17 17:51:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 3,877 ms |
コンパイル使用メモリ | 194,252 KB |
最終ジャッジ日時 | 2025-01-10 12:43:43 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#pragma gcc optimize("Ofast") #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; int l = 0, r = n - 1, szl = 1, szr = 1; while (m--) { char c; cin >> c; if (c == 'L') { if (!l) { if (l + 1 == r) szl += szr, szr = 0; else if (l != r) ++szl; } if (l) --l; if (r) --r; } else { if (r >= n - 1) { if (l + 1 == r) szr += szl, szl = 0; else if (l != r) ++szr; } if (l < n - 1) ++l; if (r < n - 1) ++r; } } int i = 0; vector<int> ans(n); for (; i < szl; ++i) ans[l] += a[i]; for (; i < n - szr; ++i) ans[++l] = a[i]; for (; i < n; ++i) ans[r] += a[i]; for (auto p : ans) cout << p << ' '; cout << '\n'; }