結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
nasu_ysmr
|
| 提出日時 | 2020-04-16 13:13:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| コード長 | 1,197 bytes |
| コンパイル時間 | 1,561 ms |
| コンパイル使用メモリ | 166,864 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 19:15:56 |
| 合計ジャッジ時間 | 3,621 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M,pos=0,length,R=1,L=1;
cin >> N >> M;
int a[N];
length=N;
char opr;
for(int i=0; i<N; i++){
cin >> a[i];
}
cin >> opr;
if(opr=='R'){
pos=1;
R++;
}else{
pos=0;
L++;
}
length--;
for(int i=1; i<M; i++){
cin >> opr;
if(opr=='R'){
if(pos==N-length){
if(length>1){
length--;
R++;
pos++;
}
}else{
pos++;
}
}else{
if(pos==0){
if(length>1){
length--;
L++;
}
}else{
pos--;
}
}
}
for(int i=0; i<L-1; i++){
a[L-1]+=a[i];
a[i]=0;
}
for(int i=N-1; i>N-R; i--){
a[N-R]+=a[i];
a[i]=0;
}
for(int i=0; i<pos; i++){
cout << 0 << " ";
}
for(int i=L-1; i<=N-R; i++){
cout << a[i] << " ";
}
for(int i=0; i<(N-length-pos); i++){
cout << 0 << " ";
}
return 0;
}
nasu_ysmr