結果

問題 No.1021 Children in Classrooms
ユーザー polyester
提出日時 2020-04-11 15:13:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 89,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 02:44:02
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  deque<ll> a;
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  string s;
  cin >> s;
  for(int i = 0; i < m; i++){
    int tmp = 0;
    if(s[i] == 'L'){
      tmp += a.front();
      a.pop_front();
      tmp += a.front();
      a.pop_front();
      a.push_front(tmp);
      a.push_back(0);
    }else{
      tmp += a.back();
      a.pop_back();
      tmp += a.back();
      a.pop_back();
      a.push_back(tmp);
      a.push_front(0);
    }
  }
  for(int i = 0; i < n; i++){
    cout << a.front() << " ";
    a.pop_front();
  }
  cout << endl;
  return 0;
}
0