結果

問題 No.1021 Children in Classrooms
ユーザー StrorkisStrorkis
提出日時 2020-04-11 11:27:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 72,868 KB
実行使用メモリ 4,664 KB
最終ジャッジ日時 2023-10-19 00:09:18
合計ジャッジ時間 4,515 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 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 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 77 ms
4,664 KB
testcase_10 AC 78 ms
4,664 KB
testcase_11 AC 77 ms
4,664 KB
testcase_12 AC 77 ms
4,664 KB
testcase_13 AC 77 ms
4,664 KB
testcase_14 AC 77 ms
4,664 KB
testcase_15 AC 58 ms
4,448 KB
testcase_16 AC 59 ms
4,460 KB
testcase_17 AC 61 ms
4,484 KB
testcase_18 AC 81 ms
4,664 KB
testcase_19 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <deque>

int main() {
    int N, M;
    std::cin >> N >> M;

    std::deque<int> deq;
    for (int i = 0; i < N; i++) {
        int a;
        std::cin >> a;
        deq.push_back(a);
    }

    std::string S;
    std::cin >> S;
    
    for (char c : S) {
        if (c == 'L') {
            int a = deq.front();
            deq.pop_front();
            int b = deq.front();
            deq.pop_front();
            deq.push_front(a + b);
            deq.push_back(0);
        }
        else {
            int a = deq.back();
            deq.pop_back();
            int b = deq.back();
            deq.pop_back();
            deq.push_back(a + b);
            deq.push_front(0);
        }
    }

    std::cout << deq.front();
    for (int i = 1; i < N; i++)
        std::cout << " " << deq[i];
    std::cout << "\n";
}
0