結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
Shibuyap
|
| 提出日時 | 2020-04-18 00:57:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 2,000 ms |
| コード長 | 1,205 bytes |
| コンパイル時間 | 1,410 ms |
| コンパイル使用メモリ | 168,612 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 19:08:02 |
| 合計ジャッジ時間 | 4,178 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005
int main() {
int n, m;
cin >> n >> m;
int a[n];
rep(i,n)cin >> a[i];
string s;
cin >> s;
int x = 0;
int y = n-1;
int now = 0;
int nowx = 0;
int nowy = n - 1;
rep(i,m){
if(s[i] == 'L'){
now--;
nowx--;
nowy--;
}else{
now++;
nowx++;
nowy++;
}
x = max(x, -now);
y = min(y, n-1-now);
nowx = max(nowx, 0);
nowx = min(nowx, n-1);
nowy = max(0, nowy);
nowy = min(n-1,nowy);
}
int ans[n] = {};
rep(i,n){
if(i <= x){
ans[nowx] += a[i];
}else if(i >= y){
ans[nowy] += a[i];
}else{
ans[i+now] += a[i];
}
}
rep(i,n){
cout << ans[i];
if(i == n - 1)cout << endl;
else cout << ' ';
}
return 0;
}
Shibuyap