結果

問題 No.1021 Children in Classrooms
ユーザー stoqstoq
提出日時 2020-04-11 07:28:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,946 bytes
コンパイル時間 5,360 ms
コンパイル使用メモリ 174,520 KB
実行使用メモリ 5,492 KB
最終ジャッジ日時 2023-10-17 13:43:01
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 34 ms
5,392 KB
testcase_10 AC 35 ms
5,396 KB
testcase_11 AC 35 ms
5,240 KB
testcase_12 AC 33 ms
5,392 KB
testcase_13 AC 33 ms
5,392 KB
testcase_14 AC 34 ms
5,392 KB
testcase_15 AC 26 ms
5,000 KB
testcase_16 AC 25 ms
4,908 KB
testcase_17 AC 27 ms
5,072 KB
testcase_18 AC 34 ms
5,492 KB
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  deque<ll> deq;
  rep(i, n)
  {
    ll a;
    cin >> a;
    deq.push_back(a);
  }
  string s;
  cin >> s;
  rep(i, m)
  {
    if (s[i] == 'L')
    {
      ll a = deq.front();
      deq.pop_front();
      ll b = deq.front();
      deq.pop_front();
      deq.push_front(a + b);
      deq.push_back(0);
    }
    else
    {
      ll a = deq.back();
      deq.pop_back();
      ll b = deq.back();
      deq.pop_back();
      deq.push_back(a + b);
      deq.push_front(0);
    }
  }
  rep(i, n) cout << deq[i] << (i == n - 1 ? "\n" : " ");

  return 0;
}
0