結果

問題 No.1619 Coccinellidae
ユーザー ks2mks2m
提出日時 2021-07-22 21:52:45
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,012 bytes
コンパイル時間 5,002 ms
コンパイル使用メモリ 74,776 KB
実行使用メモリ 61,152 KB
最終ジャッジ日時 2023-09-24 16:36:45
合計ジャッジ時間 9,051 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,820 KB
testcase_01 AC 246 ms
58,304 KB
testcase_02 AC 252 ms
60,588 KB
testcase_03 AC 124 ms
55,748 KB
testcase_04 AC 249 ms
61,152 KB
testcase_05 AC 222 ms
58,224 KB
testcase_06 AC 126 ms
55,540 KB
testcase_07 AC 231 ms
58,724 KB
testcase_08 AC 224 ms
56,692 KB
testcase_09 AC 125 ms
55,764 KB
testcase_10 AC 204 ms
58,060 KB
testcase_11 AC 229 ms
58,048 KB
testcase_12 WA -
testcase_13 AC 244 ms
60,916 KB
testcase_14 AC 252 ms
60,952 KB
testcase_15 WA -
testcase_16 AC 125 ms
55,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
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();
		long m = sc.nextLong();
		long k = sc.nextLong();
		sc.close();

		long last = m - (long) (n - 1) * (n - 2) / 2;
		long sum = 0;
		int s = 0;
		int x = 0;
		for (int i = 1; i < n; i++) {
			sum += n - i;
			if (sum >= k) {
				s = i;
				sum -= n - i;
				x = (int) (k - sum);
				break;
			}
		}
		List<Integer> list = new ArrayList<>();
		int cnt = 0;
		if (cnt == x) {
			list.add(s - 1);
		}
		for (int i = s; i < n; i++) {
			list.add(i);
			cnt++;
			if (cnt == x) {
				list.add(s - 1);
			}
		}
		for (int i = s - 2; i >= 0; i--) {
			list.add(i);
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			if (list.get(i) == n - 1) {
				pw.println(last);
			} else {
				pw.println(list.get(i));
			}
		}
		pw.flush();
	}
}
0