結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-20 21:01:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 1,600 ms |
| コンパイル使用メモリ | 173,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 22:35:26 |
| 合計ジャッジ時間 | 4,188 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
int main() {
int n, m;
cin >> n >> m;
deque<int> deq;
rep(i,n) {
int a;
cin >> a;
deq.push_back(a);
}
string s;
cin >> s;
rep(i,s.size()) {
if (s[i]=='L') {
int l1 = deq.front(); deq.pop_front();
int l2 = deq.front(); deq.pop_front();
deq.push_front(l1+l2);
deq.push_back(0);
} else {
int r1 = deq.back(); deq.pop_back();
int r2 = deq.back(); deq.pop_back();
deq.push_back(r1+r2);
deq.push_front(0);
}
}
rep(i,n) {
int ans = deq.front(); deq.pop_front();
cout << ans << " ";
}
cout << endl;
}