結果

問題 No.1837 Same but Different
ユーザー ks2mks2m
提出日時 2022-02-11 22:22:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,023 bytes
コンパイル時間 5,306 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-10 03:57:11
合計ジャッジ時間 11,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
43,288 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 120 ms
39,628 KB
testcase_04 WA -
testcase_05 AC 160 ms
40,188 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 157 ms
40,252 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 157 ms
39,896 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 167 ms
40,332 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 135 ms
55,920 KB
testcase_20 WA -
testcase_21 AC 133 ms
55,776 KB
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
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();
		sc.close();

		List<Integer> a = new ArrayList<>();
		int x = 9;
		int ta = 0;
		for (int i = 0; i < n; i++) {
			a.add(x);
			ta += x;
			x += 3;
		}

		List<Integer> b = new ArrayList<>();
		int y = 7;
		int tb = 0;
		for (int i = 0; i < n + 1; i++) {
			b.add(y);
			tb += y;
			y += 3;
		}
		int e = (3 - n % 3) % 3;
		for (int i = 0; i < e; i++) {
			b.set(b.size() - 1 - i, b.get(b.size() - 1 - i) + 1);
			tb++;
		}

		StringBuilder sb = new StringBuilder();
		for (int i : a) {
			sb.append(i).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());

		int rem = tb - ta;
		sb = new StringBuilder();
		for (int i : b) {
			if (i != rem) {
				sb.append(i).append(' ');
			}
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
		
	}
}
0