結果
問題 |
No.1650 Moving Coins
|
ユーザー |
![]() |
提出日時 | 2021-08-29 09:14:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 396 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 5,277 ms |
コンパイル使用メモリ | 339,672 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 03:34:49 |
合計ジャッジ時間 | 16,525 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using namespace std; namespace mp = boost::multiprecision; int main(){ int N,M=0; cin>>N; vector<int> A(N); for(int i=0;i<N;i++){ cin>>A[i]; } for(int i=0;i<N;i++){ int temp; cin>>temp; A[i]=temp-A[i]; M+=abs(A[i]); } vector<int> order(0); for(int i=0;i<N;i++){ if(A[i]<=0){ order.push_back(i); }else{ int j=i; while(j<N && A[j]>0){ ++j; } for(int k=j-1;k>=i;--k){ order.push_back(k); } i=j-1; } } cout<<M<<endl; for(int i=0;i<N;i++){ for(int j=0;j<abs(A[order[i]]);++j){ cout<<(order[i]+1)<<' '<<(A[order[i]]<0?'L':'R')<<endl; } } }