結果

問題 No.1021 Children in Classrooms
ユーザー Mayimg
提出日時 2020-04-12 00:00:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 4,393 ms
コンパイル使用メモリ 198,024 KB
最終ジャッジ日時 2025-01-09 17:30:34
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  deque<int> a;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  string s;
  cin >> s;
  for (char c : s) {
    if (c == 'L') {
      int x = a.front();
      a.pop_front();
      a.front() += x;
      a.push_back(0);
    } else {
      int x = a.back();
      a.pop_back();
      a.back() += x;
      a.push_front(0);
    }
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}
0