結果

問題 No.1650 Moving Coins
ユーザー yuji9511yuji9511
提出日時 2021-08-20 22:09:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,855 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 201,156 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2024-04-22 04:46:47
合計ジャッジ時間 7,829 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 42 ms
7,052 KB
testcase_09 WA -
testcase_10 AC 43 ms
7,204 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 61 ms
8,476 KB
testcase_20 AC 63 ms
8,476 KB
testcase_21 AC 63 ms
8,476 KB
testcase_22 AC 63 ms
8,604 KB
testcase_23 AC 63 ms
8,476 KB
testcase_24 AC 19 ms
5,376 KB
testcase_25 AC 19 ms
5,472 KB
testcase_26 AC 44 ms
6,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
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; }

void solve(){
  ll N;
  cin >> N;
  vll A(N), B(N);
  rep(i,0,N) cin >> A[i];
  rep(i,0,N) cin >> B[i];
  ll idx = -1;
  vector<pair<int, char> > ans;
  rep(i,0,N){
    bool ok = false;
    if(i == 0){
      if(B[i] <= A[i]) ok = true;
    }else{
      if(B[i] < A[i-1]) ok = true;
    }

    if(i == N-1){
      if(B[i] >= A[i]) ok = true;
    }else{
      if(B[i] < A[i+1]) ok = true;
    }
    if(ok){
      idx = i;
      break;
    }
  }
  assert(idx != -1);
  rrep(i,idx,0){
    ll diff = A[i] - B[i];
    if(diff > 0){
      rep(n,0,diff){
        ans.push_back({i+1, 'L'});
      }
    }else{
      rep(n,0,-diff){
        ans.push_back({i+1, 'R'});
      }
    }
  }
  rep(i,idx+1,N){
    ll diff = A[i] - B[i];
    if(diff > 0){
      rep(n,0,diff){
        ans.push_back({i+1, 'L'});
      }
    }else{
      rep(n,0,-diff){
        ans.push_back({i+1, 'R'});
      }
    }
  }
  print(ans.size());
  for(auto &e: ans){
    print(e.first, e.second);
  }

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}
0