結果

問題 No.1650 Moving Coins
ユーザー abc3
提出日時 2021-08-20 22:56:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,584 bytes
コンパイル時間 2,661 ms
コンパイル使用メモリ 205,448 KB
最終ジャッジ日時 2025-01-24 00:14:26
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <string>
#include <sstream>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using P=pair<ll,ll>;
const int INF=1001001001;
const int mod=1e9+7;
void solve(){
int n;
cin>>n;
vector<int>a(n+2),b(n+1);
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];
a[0]=-INF;a[n+1]=INF;
vector<P>q;
for(int i=1;i<=n;i++){
int p=abs(lower_bound(a.begin(),a.end(),b[i])-a.begin());
if(p==n+1){p--;}
q.emplace_back(abs(p-i),i);//cout<<i<<" a"<<p<<endl;
}
sort(q.begin(),q.end());
vector<pair<int,char>>ans;
rep(z,n){
int i=q[z].second;//cout<<q[z].first<<" "<<i<<endl;
while(abs(b[i]-a[i])){
int dis=b[i]-a[i];
char dir=(dis<0?'L':'R');
ans.emplace_back(i,dir);
if(dir=='L'){a[i]--;}
else{a[i]++;}
}
}
cout<<ans.size()<<endl;
for(auto u:ans){
cout<<u.first<<" "<<u.second<<endl;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0