結果

問題 No.1021 Children in Classrooms
ユーザー bonKotsubonKotsu
提出日時 2021-06-20 21:01:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 171,204 KB
実行使用メモリ 4,588 KB
最終ジャッジ日時 2023-09-05 01:35:07
合計ジャッジ時間 5,135 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,504 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 69 ms
4,456 KB
testcase_10 AC 69 ms
4,584 KB
testcase_11 AC 70 ms
4,424 KB
testcase_12 AC 69 ms
4,376 KB
testcase_13 AC 70 ms
4,384 KB
testcase_14 AC 69 ms
4,432 KB
testcase_15 AC 52 ms
4,380 KB
testcase_16 AC 53 ms
4,376 KB
testcase_17 AC 55 ms
4,376 KB
testcase_18 AC 73 ms
4,588 KB
testcase_19 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

int main() {
  int n, m;
  cin >> n >> m;
  deque<int> deq;
  rep(i,n) {
    int a;
    cin >> a;
    deq.push_back(a);
  }
  string s;
  cin >> s;
  rep(i,s.size()) {
    if (s[i]=='L') {
      int l1 = deq.front(); deq.pop_front();
      int l2 = deq.front(); deq.pop_front();
      deq.push_front(l1+l2);
      deq.push_back(0);
    } else {
      int r1 = deq.back(); deq.pop_back();
      int r2 = deq.back(); deq.pop_back();
      deq.push_back(r1+r2);
      deq.push_front(0);
    }
  }
  rep(i,n) {
    int ans = deq.front(); deq.pop_front();
    cout << ans << " ";
  }
  cout << endl;


}
0