結果

問題 No.1021 Children in Classrooms
ユーザー ateate
提出日時 2020-04-19 14:53:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,152 bytes
コンパイル時間 2,693 ms
コンパイル使用メモリ 203,528 KB
実行使用メモリ 17,664 KB
最終ジャッジ日時 2024-04-15 13:26:33
合計ジャッジ時間 9,265 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  vector<ll> a(n);
  cin>>a;
  string s;
  cin>>s;

  int state = 0;
  set<pll> st;
  rep(i,n)st.emplace(i,a[i]);
  rep(i,m){
    if(s[i]=='L'){
      auto itr = st.lower_bound({state+1,-1});
      state--;
      if((*itr).first!=state+2)continue;
      auto itr2 = begin(st);
      st.emplace(0,(*itr2).second+(*itr).second);
      st.erase(itr);
      st.erase(itr2);
    }
    if(s[i]=='R'){
      auto itr = st.lower_bound({state+n-2,-1});
      state++;
      if((*itr).first!=state+n-3)continue;
      auto itr2 = --end(st);
      st.emplace(n-1,(*itr2).second+(*itr).second);
      st.erase(itr);
      st.erase(itr2);
    }
  }
  vector<ll> ans(n);
  for(auto [i,v]:st){
    if(state>0){
      if(i==n-1)ans[i]=v;
      else ans[i+state]=v;
    }
    if(state<0){
      if(i==0)ans[i]=v;
      else ans[i+state]=v;
    }
    if(state==0){
      ans[i]=v;
    }
    dump(i,v);
  }
  rep(i,n)cout<<ans[i]<<endl;

}
0