結果

問題 No.1650 Moving Coins
ユーザー みここみここ
提出日時 2021-08-20 21:45:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 64,028 KB
実行使用メモリ 4,988 KB
最終ジャッジ日時 2023-08-04 06:00:59
合計ジャッジ時間 11,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 251 ms
4,380 KB
testcase_04 AC 192 ms
4,376 KB
testcase_05 AC 233 ms
4,380 KB
testcase_06 AC 258 ms
4,376 KB
testcase_07 AC 265 ms
4,376 KB
testcase_08 AC 312 ms
4,376 KB
testcase_09 AC 316 ms
4,376 KB
testcase_10 AC 323 ms
4,376 KB
testcase_11 AC 335 ms
4,376 KB
testcase_12 AC 311 ms
4,380 KB
testcase_13 AC 298 ms
4,380 KB
testcase_14 AC 321 ms
4,376 KB
testcase_15 AC 285 ms
4,376 KB
testcase_16 AC 335 ms
4,376 KB
testcase_17 AC 318 ms
4,380 KB
testcase_18 AC 342 ms
4,548 KB
testcase_19 AC 369 ms
4,936 KB
testcase_20 AC 376 ms
4,924 KB
testcase_21 AC 376 ms
4,840 KB
testcase_22 AC 375 ms
4,988 KB
testcase_23 AC 371 ms
4,844 KB
testcase_24 AC 267 ms
4,380 KB
testcase_25 AC 271 ms
4,376 KB
testcase_26 AC 114 ms
4,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[200005], b[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    int ans = 0;
    for(int i = 0; i < n; i++) ans += abs(a[i] - b[i]);
    cout << ans << endl;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            for(int j = 0; j < a[i] - b[i]; j++) cout << i + 1 << " L" << endl;
            a[i] = b[i];
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(a[i] < b[i]){
            for(int j = 0; j < b[i] - a[i]; j++) cout << i + 1 << " R" << endl;
            a[i] = b[i];
        }
    }
}
0