結果

問題 No.478 一般門松列列
ユーザー 37zigen
提出日時 2017-01-28 01:25:22
言語 Java
(openjdk 23)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 2,403 ms
コンパイル使用メモリ 76,608 KB
実行使用メモリ 51,072 KB
最終ジャッジ日時 2024-12-23 18:45:06
合計ジャッジ時間 13,372 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.SynchronousQueue;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int upper = 1_000_000_00;
		int lower = upper - 1;
		int pre = -1;
		for (int i = 0; i < n - k; ++i) {
			if (i % 2 == 0) {
				System.out.print(upper);
				pre = upper;
				++upper;
			} else {
				System.out.print(lower);
				pre = lower;
				--lower;
			}
			if (i != n - 1)
				System.out.print(" ");
		}
		for (int i = n - k; i < n; ++i) {	
			System.out.print(pre);
			if (i != n - 1)
				System.out.print(" ");
		}
		System.out.println();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0