結果
問題 |
No.1021 Children in Classrooms
|
ユーザー |
![]() |
提出日時 | 2020-04-12 11:13:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 823 bytes |
コンパイル時間 | 1,652 ms |
コンパイル使用メモリ | 172,112 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 02:17:38 |
合計ジャッジ時間 | 3,645 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; int main(){ int n, m; cin >> n >> m; vector<int> a(n); rep(i,n) cin >> a[i]; string s; cin >> s; int top = a[0], back = a[n - 1]; deque<int> que; for (int i = 1; i < n - 1; i++) que.push_back(a[i]); for (int i = 0; i < m; i++) { if (s[i] == 'L') { que.push_back(back); back = 0; top += que.front(); que.pop_front(); } else { que.push_front(top); top = 0; back += que.back(); que.pop_back(); } //cout << top << " " << back << endl; } cout << top << " "; while (!que.empty()) cout << que.front() << " ", que.pop_front(); cout << back << endl; return 0; }