結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
hiroaki0615
|
| 提出日時 | 2020-04-10 21:51:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 1,406 bytes |
| コンパイル時間 | 672 ms |
| コンパイル使用メモリ | 70,144 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 20:11:17 |
| 合計ジャッジ時間 | 2,228 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
vector<ll> A(N);
for (auto& a : A) {
cin >> a;
}
string S;
cin >> S;
int l = 0, r = N - 1;
int l_cnt = 0, r_cnt = 0;
rep(i, 0, M) {
if (S[i] == 'L' && r_cnt < N - 1) {
++r_cnt;
if (l_cnt) {
--l_cnt;
}
else {
A[l + 1] += A[l];
++l;
}
}
else if (S[i] == 'R' && l_cnt < N - 1) {
++l_cnt;
if (r_cnt) {
--r_cnt;
}
else {
A[r - 1] += A[r];
--r;
}
}
}
rep(i, 0, l_cnt) {
cout << 0 << ' ';
}
rep(i, l, r + 1) {
cout << A[i] << ' ';
}
rep(i, 0, r_cnt) {
cout << 0 << ' ';
}
cout << endl;
return 0;
}
hiroaki0615