結果

問題 No.1650 Moving Coins
ユーザー abc3abc3
提出日時 2021-08-20 22:56:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,584 bytes
コンパイル時間 2,527 ms
コンパイル使用メモリ 209,044 KB
実行使用メモリ 12,548 KB
最終ジャッジ日時 2024-04-22 06:32:56
合計ジャッジ時間 13,754 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 171 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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 WA -
testcase_20 AC 331 ms
11,524 KB
testcase_21 WA -
testcase_22 AC 314 ms
11,524 KB
testcase_23 AC 313 ms
11,524 KB
testcase_24 AC 240 ms
5,472 KB
testcase_25 AC 252 ms
5,468 KB
testcase_26 AC 62 ms
9,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=1e9+7;

    void solve(){
        int n;
        cin>>n;
        vector<int>a(n+2),b(n+1);
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=n;i++) cin>>b[i];
        a[0]=-INF;a[n+1]=INF;
        vector<P>q;
        for(int i=1;i<=n;i++){
            int p=abs(lower_bound(a.begin(),a.end(),b[i])-a.begin());
            if(p==n+1){p--;}
            q.emplace_back(abs(p-i),i);//cout<<i<<" a"<<p<<endl;
        }
        sort(q.begin(),q.end());
        vector<pair<int,char>>ans;
        rep(z,n){
            int i=q[z].second;//cout<<q[z].first<<" "<<i<<endl;
            while(abs(b[i]-a[i])){
                int dis=b[i]-a[i];
                char dir=(dis<0?'L':'R');
                ans.emplace_back(i,dir);
                if(dir=='L'){a[i]--;}
                else{a[i]++;}
            }
        }
        cout<<ans.size()<<endl;
        for(auto u:ans){
            cout<<u.first<<" "<<u.second<<endl;
        }
    }  

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        solve();   

        return 0;
    }
0