結果

問題 No.1837 Same but Different
ユーザー ks2mks2m
提出日時 2022-02-11 22:14:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 894 bytes
コンパイル時間 3,872 ms
コンパイル使用メモリ 75,820 KB
実行使用メモリ 58,612 KB
最終ジャッジ日時 2023-09-10 03:30:01
合計ジャッジ時間 11,011 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,728 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 121 ms
55,916 KB
testcase_04 WA -
testcase_05 AC 151 ms
56,660 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 154 ms
56,492 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 160 ms
55,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 165 ms
55,868 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 130 ms
55,816 KB
testcase_20 WA -
testcase_21 AC 130 ms
55,604 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;
		}

		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