結果

問題 No.1650 Moving Coins
ユーザー 👑 kmjpkmjp
提出日時 2021-08-20 22:28:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 315 ms / 2,000 ms
コード長 1,260 bytes
コンパイル時間 2,521 ms
コンパイル使用メモリ 199,020 KB
実行使用メモリ 25,788 KB
最終ジャッジ日時 2024-04-22 05:13:56
合計ジャッジ時間 12,942 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 247 ms
6,940 KB
testcase_04 AC 190 ms
6,940 KB
testcase_05 AC 235 ms
6,944 KB
testcase_06 AC 263 ms
6,940 KB
testcase_07 AC 269 ms
6,940 KB
testcase_08 AC 279 ms
6,940 KB
testcase_09 AC 296 ms
6,944 KB
testcase_10 AC 280 ms
6,940 KB
testcase_11 AC 293 ms
6,940 KB
testcase_12 AC 275 ms
6,940 KB
testcase_13 AC 277 ms
6,940 KB
testcase_14 AC 289 ms
6,944 KB
testcase_15 AC 272 ms
6,944 KB
testcase_16 AC 286 ms
6,944 KB
testcase_17 AC 276 ms
6,940 KB
testcase_18 AC 289 ms
6,940 KB
testcase_19 AC 315 ms
25,788 KB
testcase_20 AC 310 ms
7,044 KB
testcase_21 AC 315 ms
16,292 KB
testcase_22 AC 304 ms
6,944 KB
testcase_23 AC 305 ms
6,940 KB
testcase_24 AC 261 ms
6,940 KB
testcase_25 AC 266 ms
6,944 KB
testcase_26 AC 42 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N;
int A[202020];
int B[202020];
vector<pair<int,char>> V;
void go(int cur) {
	
	while(A[cur]>B[cur]) {
		V.push_back({cur+1,'L'});
		A[cur]--;
	}
	while(A[cur]<B[cur]) {
		if(cur<N-1&&A[cur]+1==A[cur+1]) go(cur+1);
		V.push_back({cur+1,'R'});
		A[cur]++;
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	
	FOR(i,N) {
		go(i);
	}
	
	cout<<V.size()<<endl;
	FORR2(a,b,V) cout<<a<<" "<<b<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0