結果

問題 No.1619 Coccinellidae
ユーザー ks2mks2m
提出日時 2021-07-22 21:49:30
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 970 bytes
コンパイル時間 4,304 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 46,120 KB
最終ジャッジ日時 2023-09-24 16:28:40
合計ジャッジ時間 9,369 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
39,368 KB
testcase_01 AC 231 ms
44,704 KB
testcase_02 AC 250 ms
45,908 KB
testcase_03 RE -
testcase_04 AC 245 ms
46,068 KB
testcase_05 AC 201 ms
44,516 KB
testcase_06 AC 117 ms
39,204 KB
testcase_07 AC 214 ms
44,444 KB
testcase_08 AC 197 ms
44,408 KB
testcase_09 RE -
testcase_10 AC 211 ms
44,696 KB
testcase_11 AC 230 ms
44,668 KB
testcase_12 AC 116 ms
39,236 KB
testcase_13 AC 237 ms
46,120 KB
testcase_14 AC 246 ms
45,896 KB
testcase_15 AC 117 ms
39,128 KB
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

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;
		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