結果

問題 No.78 クジ付きアイスバー
ユーザー utmathutmath
提出日時 2014-11-26 00:16:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 105,116 KB
実行使用メモリ 25,700 KB
最終ジャッジ日時 2023-07-28 21:02:54
合計ジャッジ時間 6,165 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,464 KB
testcase_01 AC 60 ms
21,508 KB
testcase_02 AC 59 ms
21,640 KB
testcase_03 AC 60 ms
21,572 KB
testcase_04 AC 60 ms
21,568 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 61 ms
21,500 KB
testcase_17 AC 61 ms
23,612 KB
testcase_18 AC 60 ms
21,648 KB
testcase_19 WA -
testcase_20 AC 61 ms
21,560 KB
testcase_21 AC 60 ms
21,556 KB
testcase_22 WA -
testcase_23 AC 60 ms
21,568 KB
testcase_24 AC 59 ms
21,460 KB
testcase_25 AC 60 ms
23,600 KB
testcase_26 AC 61 ms
23,624 KB
testcase_27 AC 61 ms
21,592 KB
testcase_28 AC 61 ms
21,468 KB
testcase_29 AC 60 ms
21,568 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 60 ms
23,644 KB
testcase_38 AC 59 ms
21,536 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;

public class MyClass
{
    public static void Main()
    {
        var array = Array.ConvertAll<string, int>(Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries), int.Parse);
        int N = array[0];
        int K = array[1];
        var str = Console.ReadLine();
        var strNew = str;
        int cnt = 0;
        for (int i = 0; i < str.Length; i++)
        {
            cnt--;
            cnt = Math.Max(cnt, 0);
            cnt += str[i] - '0';
        }//for i
        for (int i = 0; i < strNew.Length; i++)
        {
            if (cnt > 0 && strNew[i] == '0' || strNew[i] == '2')
            {
                if (strNew[i] == '0')
                {
                    cnt--;
                }//if
                else
                {
                    cnt++;
                }//else
                strNew = strNew.Substring(0, i) + "1" + strNew.Substring(i + 1);
            }//if
        }//for i
        long res = Count(str, Math.Min(str.Length, K));
        res += (K - str.Length) / str.Length * strNew.Count(x => x == '0');
        res += Count(strNew, (K - str.Length > 0 ? K % str.Length : 0));
        Console.WriteLine(res);
    }

    private static int Count(string str, int need)
    {
        int res = 0;
        int cnt = 0;
        for (int i = 0; i < need; i++)
        {
            cnt--;
            if (cnt < 0)
            {
                res++;
                cnt++;
            }//if
            cnt += str[i] - '0';
        }//for i
        return res;
    }

}
0