結果
問題 | No.1021 Children in Classrooms |
ユーザー |
![]() |
提出日時 | 2020-04-10 21:35:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 1,308 bytes |
コンパイル時間 | 1,529 ms |
コンパイル使用メモリ | 167,184 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 19:27:11 |
合計ジャッジ時間 | 3,128 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; typedef pair<int, int> i_i; template<class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } const long double EPS = 1e-10; const long long INF = 1e18; const long double PI = acos(-1.0L); //const ll mod = 1000000007; ll a[300000]; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); ll N, M; string S; cin >> N >> M; for(int i = 0; i < N; i++) cin >> a[i]; cin >> S; ll l = 0; for(auto c : S) { if(c == 'L') { if(0 <= l and l + 1 < N) { a[l+1] += a[l]; a[l] = 0; } l++; chmin(l, N - 1); } else { if(l+N-2 >= 0 and l+N-1 < N) { a[l+N-2] += a[l+N-1]; a[l+N-1] = 0; } l--; chmax(l, -N + 1); } } for(ll i = 0; i < N; i++) { if(i != 0) cout << " "; if(l + i < 0 or i + l >= N) cout << 0; else cout << a[i+l]; } cout << endl; return 0; }