結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2014-11-26 00:15:28 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,634 bytes |
コンパイル時間 | 836 ms |
コンパイル使用メモリ | 107,008 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-10-06 16:46:44 |
合計ジャッジ時間 | 2,858 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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') { strNew = strNew.Substring(0, i) + "1" + strNew.Substring(i + 1); if (strNew[i] == '0') { cnt--; }//if else { cnt++; }//else }//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; } }