結果

問題 No.1021 Children in Classrooms
ユーザー tapienrutapienru
提出日時 2020-05-17 17:59:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 2,475 ms
コンパイル使用メモリ 207,272 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-26 03:03:46
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 34 ms
4,376 KB
testcase_11 AC 34 ms
4,376 KB
testcase_12 AC 33 ms
4,376 KB
testcase_13 AC 34 ms
4,376 KB
testcase_14 AC 33 ms
4,376 KB
testcase_15 AC 26 ms
4,348 KB
testcase_16 AC 26 ms
4,348 KB
testcase_17 AC 27 ms
4,348 KB
testcase_18 AC 33 ms
4,348 KB
testcase_19 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0