結果

問題 No.1650 Moving Coins
ユーザー kai4096_donkai4096_don
提出日時 2021-08-20 21:55:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 384 ms / 2,000 ms
コード長 989 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 168,240 KB
実行使用メモリ 6,336 KB
最終ジャッジ日時 2023-08-04 06:21:36
合計ジャッジ時間 13,485 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 258 ms
4,376 KB
testcase_04 AC 190 ms
4,380 KB
testcase_05 AC 230 ms
4,376 KB
testcase_06 AC 260 ms
4,376 KB
testcase_07 AC 262 ms
4,380 KB
testcase_08 AC 317 ms
4,760 KB
testcase_09 AC 323 ms
4,520 KB
testcase_10 AC 329 ms
4,888 KB
testcase_11 AC 338 ms
5,104 KB
testcase_12 AC 302 ms
4,384 KB
testcase_13 AC 305 ms
4,376 KB
testcase_14 AC 313 ms
4,536 KB
testcase_15 AC 286 ms
4,376 KB
testcase_16 AC 333 ms
4,836 KB
testcase_17 AC 324 ms
4,956 KB
testcase_18 AC 349 ms
5,192 KB
testcase_19 AC 372 ms
6,148 KB
testcase_20 AC 384 ms
6,268 KB
testcase_21 AC 380 ms
6,220 KB
testcase_22 AC 383 ms
6,252 KB
testcase_23 AC 379 ms
6,336 KB
testcase_24 AC 255 ms
4,384 KB
testcase_25 AC 263 ms
4,376 KB
testcase_26 AC 117 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
int main() {
    long n;
    cin >> n;
    vector<long> viA(n+1),viB(n+1);
    for(long i = 0; i < n; i++){
        cin >> viA[i];
    }
    for(long i = 0; i < n; i++){
        cin >> viB[i];
    }
    viA[n] = 2000000, viB[n] = 2000000;
    
    long nAns = 0;
    for(long i = 0; i < n; i++){
        nAns += abs(viA[i]-viB[i]);
    }
    cout << nAns << endl;
    
    long i = 0;
    long iPrev = 0;
    while(i <= n){
        if(viA[i] < viB[i]){
            i++;
            continue;
        }
        if(viA[i] > viB[i]){
            for(long j = 0; j < viA[i] - viB[i]; j++){
                cout << i+1 << " L" << endl;
            }
        }
        for(long j = i-1; j >= iPrev; j--){
            for(long k = 0; k < viB[j] - viA[j]; k++){
                cout << j+1 << " R" << endl;
            }
        }
        i++;
        iPrev = i;
    }
    return 0;
}
0