結果
問題 | No.1021 Children in Classrooms |
ユーザー |
![]() |
提出日時 | 2020-04-10 21:55:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 1,311 bytes |
コンパイル時間 | 2,498 ms |
コンパイル使用メモリ | 194,984 KB |
最終ジャッジ日時 | 2025-01-09 16:08:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int n, m;cin >> n >> m;vector<int> a(n);for (int i = 0; i < n; i++) {cin >> a.at(i);}string s;cin >> s;int l = 0, r = n, lmerge = 0, rmerge = 0;for (int i = 0; i < m; i++) {if (s.at(i) == 'L') {l--; r--;if (l < 0) {l = 0;if (r > 0) {lmerge++;} else {r = 1;}}} else {l++; r++;if (r > n) {r = n;if (l < n) {rmerge++;} else {l = n - 1;}}}}for (int i = 0; i < lmerge; i++) {a.at(lmerge) += a.at(i);a.at(i) = 0;}for (int i = n - 1; i >= n - rmerge; i--) {a.at(n - 1 - rmerge) += a.at(i);a.at(i) = 0;}for (int i = 0; i < n; i++) {int iconvert = i - l + lmerge;if (iconvert >= 0 && iconvert < n) {cout << a.at(iconvert);} else {cout << 0;}if (i == n - 1) {cout << endl;} else {cout << " ";}}}