結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2021-08-20 22:05:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 389 ms / 2,000 ms |
| コード長 | 866 bytes |
| コンパイル時間 | 1,599 ms |
| コンパイル使用メモリ | 173,584 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-10-14 03:47:32 |
| 合計ジャッジ時間 | 12,467 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
int main() {
ll N;cin>>N;
vector<ll> A(N);
vector<ll> B(N);
for(ll i=0;i<N;i++) cin>>A[i];
for(ll i=0;i<N;i++) cin>>B[i];
ll M=0;
for(ll i=0;i<N;i++) {
M+=abs(A[i]-B[i]);
}
cout<<M<<endl;
deque<ll> S;
for(ll i=0;i<N;i++) {
if(A[i]==B[i]) continue;
if(B[i]<A[i]) {
if(S.size()>0) {
while(!S.empty()) {
ll k=S.front();
S.pop_front();
for(ll j=0;j<B[k]-A[k];j++) {
cout<<k+1<<" "<<'R'<<endl;
}
}
}
for(ll j=0;j<A[i]-B[i];j++) {
cout<<i+1<<" "<<'L'<<endl;
}
}
else {
S.push_front(i);
if(i==N-1) {
while(!S.empty()) {
ll k=S.front();
S.pop_front();
for(ll j=0;j<B[k]-A[k];j++) {
cout<<k+1<<" "<<'R'<<endl;
}
}
}
}
}
return 0;
}
planes