結果

問題 No.1021 Children in Classrooms
ユーザー veqccveqcc
提出日時 2020-04-10 23:36:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 1,021 ms
コンパイル使用メモリ 109,020 KB
実行使用メモリ 4,680 KB
最終ジャッジ日時 2023-10-14 07:54:21
合計ジャッジ時間 4,335 ms
ジャッジサーバーID
(参考情報)
judge14 / 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,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 31 ms
4,352 KB
testcase_10 AC 30 ms
4,348 KB
testcase_11 AC 31 ms
4,352 KB
testcase_12 AC 30 ms
4,356 KB
testcase_13 AC 30 ms
4,380 KB
testcase_14 AC 29 ms
4,512 KB
testcase_15 AC 23 ms
4,348 KB
testcase_16 AC 22 ms
4,352 KB
testcase_17 AC 23 ms
4,348 KB
testcase_18 AC 30 ms
4,680 KB
testcase_19 AC 5 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;

    deque<int> d;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        d.push_back(a);
    }

    string s;
    cin >> s;

    for (int i = 0;  i< m; i++) {
        if (s[i] == 'L') {
            int a = d.front();
            d.pop_front();
            int b = d.front();
            d.pop_front();
            d.push_front(a + b);
            d.push_back(0);
        } else {
            int a = d.back();
            d.pop_back();
            int b = d.back();
            d.pop_back();
            d.push_back(a + b);
            d.push_front(0);
        }
    }

    for (int i = 0; i < n; i++) {
        int x = d.front();
        d.pop_front();
        cout << x << ' ';
    }

    cout << endl;
    return 0;
}
0