結果

問題 No.1650 Moving Coins
ユーザー atjh16atjh16
提出日時 2021-09-23 03:15:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 390 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 170,624 KB
実行使用メモリ 5,704 KB
最終ジャッジ日時 2023-09-18 19:46:49
合計ジャッジ時間 14,360 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 263 ms
4,380 KB
testcase_04 AC 193 ms
4,376 KB
testcase_05 AC 244 ms
4,380 KB
testcase_06 AC 268 ms
4,376 KB
testcase_07 AC 270 ms
4,376 KB
testcase_08 AC 324 ms
4,856 KB
testcase_09 AC 329 ms
4,804 KB
testcase_10 AC 328 ms
4,880 KB
testcase_11 AC 343 ms
4,904 KB
testcase_12 AC 314 ms
4,496 KB
testcase_13 AC 312 ms
4,584 KB
testcase_14 AC 327 ms
5,092 KB
testcase_15 AC 300 ms
4,388 KB
testcase_16 AC 340 ms
5,000 KB
testcase_17 AC 324 ms
5,024 KB
testcase_18 AC 352 ms
5,216 KB
testcase_19 AC 378 ms
5,616 KB
testcase_20 AC 389 ms
5,580 KB
testcase_21 AC 384 ms
5,704 KB
testcase_22 AC 379 ms
5,556 KB
testcase_23 AC 390 ms
5,596 KB
testcase_24 AC 280 ms
4,376 KB
testcase_25 AC 277 ms
4,380 KB
testcase_26 AC 113 ms
4,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n;
int a[200000], b[200000];
vector<int> c;
vector<bool> d;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++)
		cin >> b[i];

	for (int i = 0; i < n; i++) {
		if (b[i] == a[i])
			continue;

		if (b[i] < a[i]) {
			for (int j = 0; j < a[i] - b[i]; j++) {
				c.push_back(i + 1);
				d.push_back(0);
			}
		}

		if (b[i] > a[i]) {
			int t = i;

			while (t < n && b[t] > a[t])
				t++;

			for (int j = t - 1; j >= i; j--) {
				for (int k = 0; k < b[j] - a[j]; k++) {
					c.push_back(j + 1);
					d.push_back(1);
				}
			}

			i = t - 1;
		}
	}

	cout << c.size() << endl;

	for (int i = 0; i < c.size(); i++) {
		cout << c[i];

		if (d[i])
			cout << " R" << endl;
		else
			cout << " L" << endl;
	}
}
0