結果

問題 No.1021 Children in Classrooms
ユーザー iqueue02iqueue02
提出日時 2020-04-12 11:13:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 823 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 173,456 KB
実行使用メモリ 5,300 KB
最終ジャッジ日時 2023-10-22 00:56:17
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 78 ms
5,092 KB
testcase_10 AC 78 ms
5,092 KB
testcase_11 AC 77 ms
5,092 KB
testcase_12 AC 77 ms
5,096 KB
testcase_13 AC 77 ms
5,096 KB
testcase_14 AC 77 ms
5,096 KB
testcase_15 AC 59 ms
4,844 KB
testcase_16 AC 60 ms
4,848 KB
testcase_17 AC 62 ms
4,876 KB
testcase_18 AC 82 ms
5,300 KB
testcase_19 AC 8 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
} 
0