結果

問題 No.1650 Moving Coins
ユーザー ぷらぷら
提出日時 2021-12-05 15:40:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 847 bytes
コンパイル時間 2,794 ms
コンパイル使用メモリ 202,504 KB
実行使用メモリ 5,716 KB
最終ジャッジ日時 2023-09-21 14:03:03
合計ジャッジ時間 17,627 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 260 ms
4,380 KB
testcase_04 AC 202 ms
4,376 KB
testcase_05 AC 238 ms
4,376 KB
testcase_06 AC 263 ms
4,380 KB
testcase_07 AC 270 ms
4,376 KB
testcase_08 AC 324 ms
4,480 KB
testcase_09 AC 329 ms
4,440 KB
testcase_10 AC 328 ms
4,612 KB
testcase_11 AC 338 ms
4,884 KB
testcase_12 AC 304 ms
4,376 KB
testcase_13 AC 308 ms
4,376 KB
testcase_14 AC 330 ms
4,552 KB
testcase_15 AC 299 ms
4,376 KB
testcase_16 AC 343 ms
4,884 KB
testcase_17 AC 328 ms
4,940 KB
testcase_18 AC 356 ms
5,260 KB
testcase_19 AC 383 ms
5,544 KB
testcase_20 AC 390 ms
5,684 KB
testcase_21 AC 389 ms
5,552 KB
testcase_22 AC 390 ms
5,596 KB
testcase_23 AC 396 ms
5,544 KB
testcase_24 AC 268 ms
4,376 KB
testcase_25 AC 271 ms
4,380 KB
testcase_26 AC 115 ms
5,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>A(N),B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<int>tmp1,tmp2;
    long long ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        ans += abs(A[i]-B[i]);
        if(A[i] < B[i]) {
            tmp1.push_back(i);
        }
        else {
            tmp2.push_back(i);
        }
    }
    reverse(tmp1.begin(),tmp1.end());
    cout << ans << endl;
    for(int i = 0; i < tmp1.size(); i++) {
        for(int j = 0; j < abs(A[tmp1[i]]-B[tmp1[i]]); j++) {
            cout << tmp1[i]+1 << " " << 'R' << endl;
        }
    }
    for(int i = 0; i < tmp2.size(); i++) {
        for(int j = 0; j < abs(A[tmp2[i]]-B[tmp2[i]]); j++) {
            cout << tmp2[i]+1 << " " << 'L' << endl;
        }
    }
}
0