結果

問題 No.1650 Moving Coins
ユーザー milanis48663220milanis48663220
提出日時 2021-08-20 21:49:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,417 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 123,540 KB
実行使用メモリ 7,048 KB
最終ジャッジ日時 2024-04-22 04:16:45
合計ジャッジ時間 13,166 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 WA -
testcase_03 AC 263 ms
6,940 KB
testcase_04 AC 195 ms
6,940 KB
testcase_05 AC 244 ms
6,940 KB
testcase_06 AC 263 ms
6,944 KB
testcase_07 AC 271 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 321 ms
6,944 KB
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 AC 354 ms
6,944 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 353 ms
6,948 KB
testcase_23 AC 347 ms
6,944 KB
testcase_24 AC 262 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 72 ms
7,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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; }

using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    priority_queue<P> que;
    int m = 0;
    for(int i = 0; i < n; i++) m += abs(a[i]-b[i]);
    for(int i = 0; i < n; i++) que.push(P(abs(a[i]-b[i]), i));
    cout << m << endl;
    while(!que.empty()){
        auto [d, i] = que.top(); que.pop();
        if(d == 0) continue;
        if(a[i] < b[i]) {
            a[i]++;
            cout << i+1 << ' ' << 'R' << endl;
        }else{
            a[i]--;
            cout << i+1 << ' ' << 'L' << endl;
        }
        que.push(P(abs(a[i]-b[i]), i));
    }
}
0