結果

問題 No.1650 Moving Coins
ユーザー asaringoasaringo
提出日時 2021-08-20 22:34:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,018 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 163,796 KB
実行使用メモリ 12,060 KB
最終ジャッジ日時 2024-04-22 05:23:05
合計ジャッジ時間 12,864 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 259 ms
5,376 KB
testcase_04 AC 197 ms
5,376 KB
testcase_05 AC 237 ms
5,376 KB
testcase_06 AC 272 ms
5,376 KB
testcase_07 AC 263 ms
5,376 KB
testcase_08 AC 336 ms
5,376 KB
testcase_09 AC 348 ms
5,376 KB
testcase_10 AC 345 ms
5,376 KB
testcase_11 AC 357 ms
5,376 KB
testcase_12 AC 335 ms
5,376 KB
testcase_13 AC 328 ms
5,376 KB
testcase_14 AC 357 ms
5,376 KB
testcase_15 AC 308 ms
5,376 KB
testcase_16 AC 349 ms
5,376 KB
testcase_17 AC 342 ms
5,376 KB
testcase_18 AC 371 ms
5,376 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef pair<int,int> P ;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)

int n ;
int A[202020] , B[202020] ;
bool dir[202020] ;

int main(){
    cin >> n ;
    A[0] = -10101010 ;
    rep(i,n) cin >> A[i+1] ;
    rep(i,n) cin >> B[i+1] ;
    A[n + 1] = 10101010 ;
    int sum = 0 ;
    rrep(i,1,n+1) {
        dir[i] = (A[i] <= B[i]) ;
        sum += abs(A[i] - B[i]) ;
    }
    cout << sum << endl ;
    int i = 1 ;
    while(sum > 0){
        if(i == n + 1) i = 1 ;
        if(A[i] < B[i]){
            while(A[i] + 1 != A[i + 1] && A[i] != B[i]){
                A[i]++ ;
                cout << i << " " << 'R' << endl ;
                sum-- ;
            }
        }
        if(A[i] > B[i]){
            while(A[i] - 1 != A[i - 1] && A[i] != B[i]){
                A[i]-- ;
                cout << i << " " << 'L' << endl ;
                sum-- ;
            }
        }
        i++ ;
    }
}
0