結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
|
提出日時 | 2020-04-17 18:36:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 1,723 ms |
コンパイル使用メモリ | 173,064 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 10:29:19 |
合計ジャッジ時間 | 3,808 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n, m; void f(deque<int>& a, char c) { if (c == 'L') { int tmp = a.front(); a.pop_front(); a.front() += tmp; a.push_back(0); } else if (c == 'R') { int tmp = a.back(); a.pop_back(); a.back() += tmp; a.push_front(0); } } int main() { cin >> n >> m; deque<int> a; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a.push_back(tmp); } string s; cin >> s; auto p = s.begin(); while (p != s.end()) { f(a, *p); p++; } cout << a.front(); a.pop_front(); while (!a.empty()) { cout << " " << a.front(); a.pop_front(); } cout << endl; }