結果

問題 No.1021 Children in Classrooms
ユーザー ngtkanangtkana
提出日時 2020-04-10 21:32:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,135 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 208,016 KB
実行使用メモリ 8,536 KB
最終ジャッジ日時 2023-10-13 23:26:50
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 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,348 KB
testcase_05 AC 2 ms
4,348 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 40 ms
7,868 KB
testcase_10 AC 40 ms
7,848 KB
testcase_11 AC 40 ms
7,716 KB
testcase_12 AC 39 ms
7,512 KB
testcase_13 AC 38 ms
8,536 KB
testcase_14 AC 39 ms
7,484 KB
testcase_15 AC 30 ms
6,532 KB
testcase_16 AC 31 ms
6,164 KB
testcase_17 AC 32 ms
6,516 KB
testcase_18 AC 40 ms
6,948 KB
testcase_19 AC 6 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::deque<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint l=0,r=0;
    while(m--){
        char c;std::cin>>c;
        if(c=='L'){
            if(l){
                l--;
                r++;
            }else if(1u<a.size()){
                a.at(1)+=a.at(0);
                a.pop_front();
                r++;
            }
        }
        if(c=='R'){
            if(r){
                r--;
                l++;
            }else if(1u<a.size()){
                a.at(a.size()-2)+=a.at(a.size()-1);
                a.pop_back();
                l++;
            }
        }
        assert(l+(lint)a.size()+r==n);
    }
    std::vector<lint>ans;
    while(l--)ans.push_back(0);
    ans.insert(ans.end(),ALL(a));
    while(r--)ans.push_back(0);
    for(lint i=0;i<n;i++){
        std::cout<<(i?" ":"")<<ans.at(i);
    }
    std::cout<<'\n';
}
0