結果

問題 No.78 クジ付きアイスバー
ユーザー 明智重蔵
提出日時 2015-08-04 19:28:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 2,693 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 108,160 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-11-08 00:47:21
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "Input5";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5 4");
WillReturn.Add("01200");
//2
}
else if (InputPattern == "Input2") {
WillReturn.Add("2 8");
WillReturn.Add("10");
//4
}
else if (InputPattern == "Input3") {
WillReturn.Add("10 100");
WillReturn.Add("2222222222");
//1
}
else if (InputPattern == "Input4") {
WillReturn.Add("2 5");
WillReturn.Add("01");
//3
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static int K;
static char[] SArr;
static void Main()
{
List<string> InputList = GetInputList();
K = int.Parse(InputList[0].Split(' ').Last());
SArr = InputList[1].ToCharArray();
Console.WriteLine(Solve());
}
static int Solve()
{
int HonsuuSum = 0;
int KounyuuCnt = 0;
int AtariHonsuu = 0;
//1
Action HitohakoSyori = () =>
{
foreach (char EachChar in SArr) {
if (AtariHonsuu == 0) KounyuuCnt++;
else AtariHonsuu--;
if (EachChar == '1') AtariHonsuu++;
if (EachChar == '2') AtariHonsuu += 2;
if (++HonsuuSum == K) {
return;
}
}
};
//1
HitohakoSyori();
//1
if (HonsuuSum == K) {
return KounyuuCnt;
}
//使
//
int SecondBoxKounyuuCnt = KounyuuCnt - AtariHonsuu;
if (SecondBoxKounyuuCnt <= 0) return KounyuuCnt;
//
int TotalBoxCnt = K / SArr.Length;
if (K % SArr.Length > 0) TotalBoxCnt++;
//1
int RestBoxCnt = TotalBoxCnt - 2;
//1
if (RestBoxCnt > 0) {
HonsuuSum += RestBoxCnt * SArr.Length;
KounyuuCnt += RestBoxCnt * SecondBoxKounyuuCnt;
}
//
HitohakoSyori();
return KounyuuCnt;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0