結果

問題 No.1650 Moving Coins
ユーザー startcppstartcpp
提出日時 2021-08-20 21:44:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 87,972 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-22 04:08:01
合計ジャッジ時間 12,264 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 263 ms
7,508 KB
testcase_04 AC 203 ms
7,640 KB
testcase_05 AC 246 ms
7,636 KB
testcase_06 AC 273 ms
7,636 KB
testcase_07 AC 277 ms
7,640 KB
testcase_08 AC 338 ms
9,172 KB
testcase_09 AC 347 ms
9,216 KB
testcase_10 AC 342 ms
9,356 KB
testcase_11 AC 350 ms
9,380 KB
testcase_12 AC 318 ms
8,460 KB
testcase_13 AC 316 ms
8,616 KB
testcase_14 AC 335 ms
9,024 KB
testcase_15 AC 303 ms
8,512 KB
testcase_16 AC 352 ms
9,668 KB
testcase_17 AC 342 ms
9,584 KB
testcase_18 AC 367 ms
9,848 KB
testcase_19 AC 398 ms
10,752 KB
testcase_20 AC 401 ms
10,620 KB
testcase_21 AC 408 ms
10,752 KB
testcase_22 AC 404 ms
10,624 KB
testcase_23 AC 406 ms
10,624 KB
testcase_24 AC 274 ms
7,508 KB
testcase_25 AC 275 ms
7,636 KB
testcase_26 AC 128 ms
6,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
int a[200000];
int b[200000];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	typedef pair<int, char> P;
	vector<P> ans;
	
	//まず'L'から処理する
	rep(i, n) {
		if (a[i] <= b[i]) continue;
		rep(j, a[i] - b[i]) {
			ans.push_back(P(i, 'L'));
		}
	}
	
	//次に'R'を処理する
	for (i = n - 1; i >= 0; i--) {
		if (a[i] >= b[i]) continue;
		rep(j, b[i] - a[i]) {
			ans.push_back(P(i, 'R'));
		}
	}
	
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i].first + 1 << " " << ans[i].second << endl;
	}
	return 0;
}
0