結果

問題 No.1650 Moving Coins
ユーザー ks2mks2m
提出日時 2021-08-20 22:15:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,536 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 3,094 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 75,076 KB
最終ジャッジ日時 2024-04-22 04:56:38
合計ジャッジ時間 30,086 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
41,620 KB
testcase_01 AC 139 ms
41,536 KB
testcase_02 AC 158 ms
41,408 KB
testcase_03 AC 336 ms
46,668 KB
testcase_04 AC 287 ms
44,468 KB
testcase_05 AC 320 ms
47,040 KB
testcase_06 AC 333 ms
46,968 KB
testcase_07 AC 341 ms
46,720 KB
testcase_08 AC 1,072 ms
66,560 KB
testcase_09 AC 1,103 ms
63,284 KB
testcase_10 AC 1,100 ms
65,532 KB
testcase_11 AC 1,129 ms
64,328 KB
testcase_12 AC 908 ms
62,272 KB
testcase_13 AC 905 ms
61,284 KB
testcase_14 AC 1,046 ms
64,916 KB
testcase_15 AC 803 ms
52,680 KB
testcase_16 AC 1,122 ms
66,392 KB
testcase_17 AC 1,142 ms
64,964 KB
testcase_18 AC 1,241 ms
66,780 KB
testcase_19 AC 1,457 ms
75,076 KB
testcase_20 AC 1,536 ms
71,872 KB
testcase_21 AC 1,425 ms
71,712 KB
testcase_22 AC 1,507 ms
72,132 KB
testcase_23 AC 1,480 ms
71,704 KB
testcase_24 AC 300 ms
47,200 KB
testcase_25 AC 301 ms
47,104 KB
testcase_26 AC 1,016 ms
59,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		sc.close();

		List<Integer> l = new ArrayList<>();
		List<Integer> r = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			if (a[i] > b[i]) {
				l.add(i);
			}
			if (a[i] < b[i]) {
				r.add(i);
			}
		}
		Collections.reverse(r);

		List<String> list = new ArrayList<>();
		for (int i : l) {
			int d = a[i] - b[i];
			String s = (i + 1) + " L";
			for (int j = 0; j < d; j++) {
				list.add(s);
			}
		}
		for (int i : r) {
			int d = b[i] - a[i];
			String s = (i + 1) + " R";
			for (int j = 0; j < d; j++) {
				list.add(s);
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println(list.size());
		for (String s : list) {
			pw.println(s);
		}
		pw.flush();
	}
}
0