結果

問題 No.501 穴と文字列
ユーザー Charlotte8687Charlotte8687
提出日時 2018-12-05 16:55:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,049 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 105,340 KB
実行使用メモリ 25,852 KB
最終ジャッジ日時 2023-09-26 12:32:47
合計ジャッジ時間 5,847 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
25,852 KB
testcase_01 AC 156 ms
21,776 KB
testcase_02 AC 63 ms
21,768 KB
testcase_03 AC 63 ms
21,768 KB
testcase_04 AC 63 ms
23,972 KB
testcase_05 AC 63 ms
21,944 KB
testcase_06 AC 63 ms
23,764 KB
testcase_07 AC 63 ms
21,768 KB
testcase_08 AC 63 ms
21,780 KB
testcase_09 AC 62 ms
21,716 KB
testcase_10 AC 63 ms
21,776 KB
testcase_11 AC 62 ms
21,920 KB
testcase_12 AC 62 ms
22,028 KB
testcase_13 AC 63 ms
21,852 KB
testcase_14 AC 62 ms
23,820 KB
testcase_15 AC 63 ms
21,888 KB
testcase_16 AC 65 ms
23,820 KB
testcase_17 AC 65 ms
21,848 KB
testcase_18 AC 165 ms
23,864 KB
testcase_19 AC 165 ms
21,932 KB
testcase_20 AC 167 ms
23,804 KB
testcase_21 AC 170 ms
23,812 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

namespace StudyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            const char zero = 'C';
            const char one = 'A';
            const char two = 'B';

            var inputs = Console.ReadLine().Trim().Split(' ').Select(data => int.Parse(data)).ToArray();
            var n = inputs[0];
            var d = inputs[1];

            var result = new char[n];
            var diff = d - n;

            for (int i = 0; i < n; i++)
            {
                if (diff > 0)
                {
                    result[i] = 'B';
                    diff--;
                }
                else if (diff < 0)
                {
                    result[i] = 'C';
                    diff++;
                }
                else
                {
                    result[i] = 'A';
                }
            }
            foreach (var data in result.OrderBy(data => data))
                Console.Write(data);
            Console.Write("\n");
        }
    }
}
0