結果
問題 | No.1021 Children in Classrooms |
ユーザー |
![]() |
提出日時 | 2020-04-10 21:52:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 979 bytes |
コンパイル時間 | 1,954 ms |
コンパイル使用メモリ | 168,304 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 20:14:02 |
合計ジャッジ時間 | 3,434 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FOREACH(x, a) for (auto&(x) : (a)) #define ALL(v) (v).begin(), (v).end() #define SZ(x) ll(x.size()) int main() { ll n, m; cin >> n >> m; vector<ll> a(n); REP(i, n) { cin >> a[i]; } ll l = 0, r = n - 1; string s; cin >> s; REP(i, m) { if (s[i] == 'L') { if (l < n - 1) { l++; r++; } if (1 <= l && l < n) { a[l] += a[l - 1]; a[l - 1] = 0; } } else { if (r > 0) { l--; r--; } if (0 <= r && r < n - 1) { a[r] += a[r + 1]; a[r + 1] = 0; } } } FOR(i, l, r + 1) { cout << (i < 0 || n <= i ? 0 : a[i]) << " \n"[i == r]; } }