結果

問題 No.1021 Children in Classrooms
ユーザー konchanksukonchanksu
提出日時 2020-04-11 00:14:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 73,480 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-14 09:07:50
合計ジャッジ時間 2,698 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 59 ms
4,476 KB
testcase_10 AC 62 ms
4,348 KB
testcase_11 AC 63 ms
4,424 KB
testcase_12 AC 59 ms
4,364 KB
testcase_13 AC 58 ms
4,388 KB
testcase_14 AC 58 ms
4,348 KB
testcase_15 AC 45 ms
4,348 KB
testcase_16 AC 45 ms
4,348 KB
testcase_17 AC 49 ms
4,352 KB
testcase_18 AC 67 ms
4,348 KB
testcase_19 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <deque>
#define rep(i, n) for(int (i) = (0); (i) < (n); (i)++)
using namespace std;

int main(){
    int m, n, j;
    int tmp;
    cin >> n >> m;
    deque<int> a(n, 0);
    rep(i, n) cin >> a[i];
    string s;
    cin >> s;
    
    rep(i, m){
        if(s[i] == 'L'){
            tmp = a.front();
            a.pop_front();
            tmp += a.front();
            a.pop_front();
            a.push_front(tmp);
            a.push_back(0);
        }
        
        else{
            tmp = a.back();
            a.pop_back();
            tmp += a.back();
            a.pop_back();
            a.push_back(tmp);
            a.push_front(0);
        }       
    }
    
    rep(i, n) cout << a[i] << ' ';
    cout << endl;
    
    return 0;
}
0