結果
問題 | No.1650 Moving Coins |
ユーザー | みここ |
提出日時 | 2021-08-20 21:45:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 391 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 941 ms |
コンパイル使用メモリ | 64,640 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 03:08:12 |
合計ジャッジ時間 | 11,932 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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]; } } }