結果

問題 No.501 穴と文字列
ユーザー tenten
提出日時 2020-09-10 10:12:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 54,224 KB
最終ジャッジ日時 2024-12-21 16:26:10
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int d = sc.nextInt();
    	char[] ans = new char[n];
    	for (int i = n; i > 0; i--) {
    	    if (i < d) {
    	        ans[i - 1] = 'B';
    	        d -= 2;
    	    } else if (d == 0) {
    	        ans[i - 1] = 'C';
    	    } else {
    	        ans[i - 1] = 'A';
    	        d--;
    	    }
    	}
    	Arrays.sort(ans);
    	System.out.println(ans);
    }
}
0