結果
問題 |
No.1650 Moving Coins
|
ユーザー |
|
提出日時 | 2021-08-20 22:34:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,018 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 167,680 KB |
実行使用メモリ | 11,684 KB |
最終ジャッジ日時 | 2024-10-14 04:34:28 |
合計ジャッジ時間 | 12,812 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 TLE * 1 -- * 7 |
ソースコード
#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++ ; } }