結果

問題 No.1650 Moving Coins
ユーザー risujiroh
提出日時 2021-08-20 22:27:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 3,141 ms
コンパイル使用メモリ 196,692 KB
最終ジャッジ日時 2025-01-23 23:48:04
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;

  vector<pair<int, char>> ans;

  for (int i = 0; i < n; ++i) {
    if (b[i] < a[i]) {
      for (int _ = a[i] - b[i]; _--;) {
        ans.emplace_back(i, 'L');
      }
    }
  }

  for (int i = n; i--;) {
    if (a[i] < b[i]) {
      for (int _ = b[i] - a[i]; _--;) {
        ans.emplace_back(i, 'R');
      }
    }
  }

  cout << size(ans) << '\n';
  for (auto&& [i, c] : ans) {
    cout << i + 1 << ' ' << c << '\n';
  }
}
0