結果

問題 No.1650 Moving Coins
ユーザー auauaauaua
提出日時 2021-08-20 23:40:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 1,546 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 172,464 KB
実行使用メモリ 10,348 KB
最終ジャッジ日時 2024-04-22 08:32:54
合計ジャッジ時間 7,983 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 20 ms
5,376 KB
testcase_04 AC 15 ms
5,376 KB
testcase_05 AC 18 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 19 ms
5,376 KB
testcase_08 AC 92 ms
6,092 KB
testcase_09 AC 89 ms
6,848 KB
testcase_10 AC 96 ms
6,196 KB
testcase_11 AC 96 ms
6,184 KB
testcase_12 AC 62 ms
5,376 KB
testcase_13 AC 64 ms
5,376 KB
testcase_14 AC 86 ms
5,976 KB
testcase_15 AC 51 ms
5,376 KB
testcase_16 AC 104 ms
6,456 KB
testcase_17 AC 104 ms
6,380 KB
testcase_18 AC 117 ms
7,796 KB
testcase_19 AC 147 ms
10,348 KB
testcase_20 AC 153 ms
8,576 KB
testcase_21 AC 153 ms
9,408 KB
testcase_22 AC 150 ms
8,704 KB
testcase_23 AC 151 ms
8,704 KB
testcase_24 AC 19 ms
5,376 KB
testcase_25 AC 20 ms
5,376 KB
testcase_26 AC 134 ms
10,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=INF;
const ll MAX=200010;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;



signed main(){
    ll n;cin>>n;
    vector<ll>a(n),b(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n)cin>>b[i];
    vector<ll>ans(0);
    ll now=0;
    stack<ll>st;
    ll sum=0;

    rep(i,n){
        sum+=abs(a[i]-b[i]);
        st.push(i);
        if(a[i]>b[i]){
            while(!st.empty()){
                ll k=st.top();
                ans.pb(k);
                st.pop();
            }
        }
    }
    while(!st.empty()){
        ll k=st.top();
        ans.pb(k);
        st.pop();
    }
    cout<<sum<<endl;
    rep(i,ans.size()){
        ll id=ans[i];
        if(a[id]>b[id]){
            rep(j,abs(a[id]-b[id])){
                cout<<id+1<<' '<<'L'<<endl;
            }
        }else{
            rep(j,abs(a[id]-b[id])){
                cout<<id+1<<' '<<'R'<<endl;
            }
        }
    }
}
0