結果

問題 No.1021 Children in Classrooms
ユーザー NewGardenNewGarden
提出日時 2020-04-10 22:04:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,284 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 167,664 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-10-14 00:35:29
合計ジャッジ時間 4,307 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 68 ms
4,348 KB
testcase_10 AC 69 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 68 ms
4,352 KB
testcase_13 AC 68 ms
4,348 KB
testcase_14 AC 68 ms
4,348 KB
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 AC 73 ms
4,352 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,m;
  string s;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  cin >> s;
  int pos = 0;
  rep(i,m){
    if(s[i]=='L'){
      pos--;
    } else {
      pos++;
    }
    if(pos<0 && abs(pos)<n){
      int it = -pos-1;
      a[it+1] += a[it];
      a[it] = 0;
    }
    if(pos>0 && abs(pos)<n){
      int it = n-pos;
      a[it-1] += a[it];
      a[it] = 0;
    }
  }

  if(n-1<=pos){
    rep(i,n-1) cout << 0 << " ";
    cout << a[0] << endl;
    return 0;
  }
  if((1-n)>=pos){
    cout << a[n-1] << " ";
    rep(i,n-1) cout << 0 << " ";
    cout << endl; return 0;
  }
  if(pos>0){
    rep(i,pos) cout << 0 << " ";
    for(int i=0; i<n-pos; i++) cout << a[i] << " ";
    cout << endl; return 0;
  }
  if(pos<0){
    for(int i=pos; i<n; i++) cout << a[i] << " ";
    rep(i,pos) cout << 0 << " ";
    cout << endl; return 0;
  }
  if(pos==0){
    rep(i,n) cout << a[i] << " ";
    cout << endl; return 0;
  }
  return 0;
}
0