結果

問題 No.1650 Moving Coins
ユーザー aut_jul_dur
提出日時 2021-08-20 21:52:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 1,254 bytes
コンパイル時間 3,754 ms
コンパイル使用メモリ 229,300 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-10-14 03:24:49
合計ジャッジ時間 14,079 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 9*1e18;
using ll = long long;
using mint = modint1000000007;
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 (b<a) { a=b; return 1; } return 0; }
long double PI = 3.14159265358979;
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  vector<ll> sa(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,N){
    cin>>B[i];
  }
  ll ans = 0;
  rep(i,N){
    ans += abs(A[i]-B[i]);
    sa[i] = B[i]-A[i];
  }
  cout << ans << endl;
  ll owatta = -1;
  rep(i,N){
    if(sa[i] > 0){
      continue;
    }
    else{
      for(int k = A[i];k>B[i];k--){
        cout << i+1 << " L" << endl;
      }
      for(int k = i-1;k>owatta;k--){
        for(int p = A[k];p<B[k];p++){
          cout << k+1 << " R" << endl;
        }
      }
      owatta = i;
    }
  }
  for(int i = N-1;i>owatta;i--){
    for(int k = A[i];k<B[i];k++){
      cout << i+1 << " R" << endl;
    }
  }
  return 0;
}
0