結果
問題 |
No.1650 Moving Coins
|
ユーザー |
|
提出日時 | 2021-08-20 22:30:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,529 bytes |
コンパイル時間 | 3,228 ms |
コンパイル使用メモリ | 206,824 KB |
最終ジャッジ日時 | 2025-01-23 23:50:14 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 5 WA * 19 |
ソースコード
#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),b(n); rep(i,n) cin>>a[i]; rep(i,n) cin>>b[i]; a.push_back(INF); vector<P>q; rep(i,n){ int p=lower_bound(a.begin(),a.end(),b[i])-a.begin(); if(p==n){p--;} q.emplace_back(p-i,i);//cout<<b[i]<<" "<<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+1,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; }