結果

問題 No.1021 Children in Classrooms
ユーザー 👑 jupirojupiro
提出日時 2020-04-10 21:42:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,620 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 120,352 KB
実行使用メモリ 6,680 KB
最終ジャッジ日時 2023-10-13 23:51:22
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 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 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 47 ms
6,644 KB
testcase_10 AC 47 ms
6,636 KB
testcase_11 AC 47 ms
6,608 KB
testcase_12 AC 46 ms
6,632 KB
testcase_13 AC 46 ms
6,668 KB
testcase_14 AC 45 ms
6,652 KB
testcase_15 AC 35 ms
5,684 KB
testcase_16 AC 36 ms
5,744 KB
testcase_17 AC 37 ms
5,812 KB
testcase_18 AC 46 ms
6,680 KB
testcase_19 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll N, M; scanf("%lld %lld", &N, &M);
	vector<ll> a(N); for (int i = 0; i < N; i++) scanf("%lld", &a[i]);
	string s; cin >> s;
	deque<ll> dq;
	for (int i = 0; i < N; i++) dq.push_back(a[i]);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'L') {
			ll t1 = dq.front();
			dq.pop_front();
			ll t2 = dq.front();
			dq.pop_front();
			dq.push_front(t1 + t2);
			dq.push_back(0);
		}
		else {
			ll t1 = dq.back();
			dq.pop_back();
			ll t2 = dq.back();
			dq.pop_back();
			dq.push_back(t1 + t2);
			dq.push_front(0);
		}
	}
	for (int i = 0; i < N; i++) {
		cout << dq[i];
		if (i == N - 1) cout << "\n";
		else cout << " ";
	}
	return 0;
}
0