結果
| 問題 | 
                            No.1021 Children in Classrooms
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-04-10 22:04:13 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,284 bytes | 
| コンパイル時間 | 1,753 ms | 
| コンパイル使用メモリ | 169,376 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-15 20:24:25 | 
| 合計ジャッジ時間 | 3,746 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 WA * 7 RE * 2 | 
ソースコード
#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;
}