結果
問題 |
No.1650 Moving Coins
|
ユーザー |
👑 ![]() |
提出日時 | 2021-08-20 21:43:41 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 868 bytes |
コンパイル時間 | 2,714 ms |
コンパイル使用メモリ | 107,788 KB |
最終ジャッジ日時 | 2025-01-23 23:07:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector<int> A; vector<int> B; vector<pair<int,char>> ans; int main(){ cin >> N; A.resize(N); rep(i,N) cin >> A[i]; B.resize(N); rep(i,N) cin >> B[i]; rep(i,N) if(A[i] > B[i]){ while(A[i] != B[i]){ ans.push_back({i,'L'}); A[i]--; } } for(int i=N-1; i>=0; i--) if(A[i] < B[i]){ while(A[i] != B[i]){ ans.push_back({i,'R'}); A[i]++; } } cout << ans.size() << "\n"; for(auto a : ans){ cout << (a.first+1) << " " << a.second << "\n"; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;