結果

問題 No.1021 Children in Classrooms
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-08-31 21:01:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,396 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 103,604 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 11:09:56
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
#include <deque>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
const int inf = (int)1e9; 
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}



int main(void){
    int n,m;
    cin>>n>>m;
    deque<int>dq;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        dq.push_back(a);
    }
    string s;
    cin>>s;
    for(int i=0;i<m;i++){
        if(s[i]=='L'){
            int x1 = dq.front();
            dq.pop_front();
            int x2 = dq.front();
            dq.pop_front();
            dq.push_front(x1+x2);
            dq.push_back(0);
        }
        else{
            int x1 = dq.back();
            dq.pop_back();
            int x2 = dq.back();
            dq.pop_back();
            dq.push_back(x1+x2);
            dq.push_front(0);
        }
    }
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout<<dq.front()<<endl;
        }
        else{
            cout<<dq.front()<<" ";
        }
        dq.pop_front();
    }
	return 0;
}
0