結果

問題 No.501 穴と文字列
ユーザー ぴろずぴろず
提出日時 2017-04-07 22:57:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 71,636 KB
実行使用メモリ 56,248 KB
最終ジャッジ日時 2023-08-21 07:08:33
合計ジャッジ時間 5,731 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,240 KB
testcase_01 AC 129 ms
55,936 KB
testcase_02 AC 120 ms
55,940 KB
testcase_03 AC 121 ms
55,780 KB
testcase_04 AC 121 ms
55,600 KB
testcase_05 AC 121 ms
55,928 KB
testcase_06 AC 121 ms
55,872 KB
testcase_07 AC 119 ms
56,248 KB
testcase_08 AC 120 ms
55,536 KB
testcase_09 AC 120 ms
55,660 KB
testcase_10 AC 121 ms
56,136 KB
testcase_11 AC 120 ms
55,596 KB
testcase_12 AC 120 ms
55,672 KB
testcase_13 AC 121 ms
55,924 KB
testcase_14 AC 123 ms
55,920 KB
testcase_15 AC 121 ms
55,408 KB
testcase_16 AC 120 ms
55,604 KB
testcase_17 AC 121 ms
55,780 KB
testcase_18 AC 137 ms
56,248 KB
testcase_19 AC 132 ms
55,404 KB
testcase_20 AC 139 ms
55,788 KB
testcase_21 AC 131 ms
55,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no501;

import java.util.Scanner;

public class Main {
	static int[] h = {1,2,0};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		char[] c = new char[n];
		for(int i=0;i<n;i++) {
			for(int j=0;j<=2;j++) {
				if ((i == n - 1 && d == h[j]) || (i < n - 1 && (n-1-i) * 2 >= d - h[j] && d >= h[j])) {
					c[i] = (char) ('A' + j);
					d -= h[j];
					break;
				}
			}
		}
		System.out.println(String.valueOf(c));
	}

}
0