結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-10 21:32:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 1,135 bytes |
| コンパイル時間 | 2,057 ms |
| コンパイル使用メモリ | 204,124 KB |
| 最終ジャッジ日時 | 2025-01-09 15:59:44 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n,m;std::cin>>n>>m;
std::deque<lint>a(n);
for(lint&x:a)std::cin>>x;
lint l=0,r=0;
while(m--){
char c;std::cin>>c;
if(c=='L'){
if(l){
l--;
r++;
}else if(1u<a.size()){
a.at(1)+=a.at(0);
a.pop_front();
r++;
}
}
if(c=='R'){
if(r){
r--;
l++;
}else if(1u<a.size()){
a.at(a.size()-2)+=a.at(a.size()-1);
a.pop_back();
l++;
}
}
assert(l+(lint)a.size()+r==n);
}
std::vector<lint>ans;
while(l--)ans.push_back(0);
ans.insert(ans.end(),ALL(a));
while(r--)ans.push_back(0);
for(lint i=0;i<n;i++){
std::cout<<(i?" ":"")<<ans.at(i);
}
std::cout<<'\n';
}
ngtkana