結果

問題 No.1650 Moving Coins
ユーザー bonKotsubonKotsu
提出日時 2022-07-18 13:22:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 4,543 ms
コンパイル使用メモリ 263,500 KB
実行使用メモリ 7,652 KB
最終ジャッジ日時 2023-09-13 02:26:05
合計ジャッジ時間 13,444 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 31 ms
5,312 KB
testcase_04 AC 24 ms
5,136 KB
testcase_05 AC 28 ms
5,428 KB
testcase_06 AC 31 ms
5,148 KB
testcase_07 AC 31 ms
5,452 KB
testcase_08 AC 93 ms
6,352 KB
testcase_09 AC 91 ms
6,500 KB
testcase_10 AC 96 ms
6,528 KB
testcase_11 AC 97 ms
6,548 KB
testcase_12 AC 67 ms
5,848 KB
testcase_13 AC 69 ms
6,036 KB
testcase_14 AC 89 ms
6,416 KB
testcase_15 AC 58 ms
5,844 KB
testcase_16 AC 102 ms
6,576 KB
testcase_17 AC 104 ms
6,556 KB
testcase_18 AC 113 ms
6,944 KB
testcase_19 AC 142 ms
7,432 KB
testcase_20 AC 146 ms
7,628 KB
testcase_21 AC 147 ms
7,560 KB
testcase_22 AC 147 ms
7,652 KB
testcase_23 AC 147 ms
7,452 KB
testcase_24 AC 31 ms
5,216 KB
testcase_25 AC 31 ms
5,096 KB
testcase_26 AC 114 ms
5,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
template<class T>
void chmax(T& a, T b) { a = max(a, b); };
template<class T>
void chmin(T& a, T b) { a = min(a, b); };


int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), d(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  vector<pair<int, char>> ans;
  rep(i,n) {
    if (a[i] < b[i]) d[i] = 1;
    else if (a[i] > b[i]) d[i] = -1;
  }
  rep(i,n) {
    // left
    if (d[i] == -1) { 
      rep(j,a[i]-b[i]) {
        ans.pb({i+1, 'L'});
      }
    } else if (d[i] == 1) {
      int l = i;
      int r = i;
      while (r+1<n && d[r+1] == 1) {
        r++;
      }
      for (int j = r; j >= l; j--) {
        rep(k,b[j]-a[j]) {
          ans.pb({j+1, 'R'});
        }
      }
      i = r;
    }
  }
  cout << ans.size() << endl;
  for (auto [n, c] : ans) cout << n << " " << c << "\n";  

  
}
0