結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2020-04-10 22:12:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 84 ms / 2,000 ms |
| コード長 | 1,459 bytes |
| コンパイル時間 | 1,859 ms |
| コンパイル使用メモリ | 174,360 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 20:36:26 |
| 合計ジャッジ時間 | 3,809 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
int main(){
int N, M;
cin >> N >> M;
vector<int> v;
rep(i,N){
int a;
cin >> a;
v.push_back(a);
}
string S;
cin >> S;
int L = 0, R = N-1;
int PL = 0, PR = N-1;
rep(i,S.size()){
if(S[i] == 'L'){
PL--;
PR--;
if(PL == PR){
if(PL < 0){
PL = 0;
PR = 0;
}
}else{
if(PL < 0){
PL = 0;
L++;
}
}
}else{
PL++;
PR++;
if(PL == PR){
if(PR >= N){
PL = N-1;
PR = N-1;
}
}else{
if(PR >= N){
PR = N-1;
R--;
}
}
}
}
deque<int> deq;
if(PL==PR){
int sum = 0;
rep(i,N) sum += v[i];
deq.push_back(sum);
}else{
{
int sum = 0;
rep(i,L+1) sum += v[i];
deq.push_back(sum);
}
{
REP(i,L+1,R) deq.push_back(v[i]);
}
{
int sum = 0;
REP(i,R,N) sum += v[i];
deq.push_back(sum);
}
}
rep(i,PL) deq.push_front(0);
REP(i,PR+1,N) deq.push_back(0);
rep(i,deq.size()){
if(i>0) cout << " ";
cout << deq[i];
}
cout << endl;
return 0;
}
どらら