結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
|
提出日時 | 2020-05-17 17:59:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 851 bytes |
コンパイル時間 | 2,316 ms |
コンパイル使用メモリ | 199,144 KB |
最終ジャッジ日時 | 2025-01-10 12:44:13 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; deque<int> a; for (int i = 0; i < n; ++i) { int tmp; cin >> tmp; a.emplace_back(tmp); } while (m--) { char c; cin >> c; if (c == 'L') { if (a.size() > 1) { int tmp = a[0]; a.pop_front(); tmp += a[0], a.pop_front(); a.emplace_front(tmp), a.emplace_back(0); } } else { if (a.size() > 1) { int tmp = a.back(); a.pop_back(); tmp += a.back(), a.pop_back(); a.emplace_back(tmp), a.emplace_front(0); } } } for (auto p : a) cout << p << ' '; cout << '\n'; }