結果

問題 No.1650 Moving Coins
ユーザー kai4096_donkai4096_don
提出日時 2021-08-20 21:55:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 989 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 165,440 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-22 04:26:39
合計ジャッジ時間 13,085 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 261 ms
5,376 KB
testcase_04 AC 197 ms
5,376 KB
testcase_05 AC 241 ms
5,376 KB
testcase_06 AC 270 ms
5,376 KB
testcase_07 AC 267 ms
5,376 KB
testcase_08 AC 336 ms
5,376 KB
testcase_09 AC 336 ms
5,376 KB
testcase_10 AC 340 ms
5,376 KB
testcase_11 AC 343 ms
5,376 KB
testcase_12 AC 309 ms
5,376 KB
testcase_13 AC 314 ms
5,376 KB
testcase_14 AC 337 ms
5,376 KB
testcase_15 AC 306 ms
5,376 KB
testcase_16 AC 353 ms
5,376 KB
testcase_17 AC 344 ms
5,376 KB
testcase_18 AC 370 ms
5,376 KB
testcase_19 AC 397 ms
6,400 KB
testcase_20 AC 404 ms
6,528 KB
testcase_21 AC 406 ms
6,400 KB
testcase_22 AC 397 ms
6,400 KB
testcase_23 AC 402 ms
6,400 KB
testcase_24 AC 269 ms
5,376 KB
testcase_25 AC 271 ms
5,376 KB
testcase_26 AC 130 ms
6,528 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