結果
問題 | No.281 門松と魔法(1) |
ユーザー | 14番 |
提出日時 | 2016-05-14 17:35:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,902 bytes |
コンパイル時間 | 883 ms |
コンパイル使用メモリ | 109,404 KB |
実行使用メモリ | 25,948 KB |
最終ジャッジ日時 | 2024-11-06 19:51:42 |
合計ジャッジ時間 | 3,598 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
23,656 KB |
testcase_01 | AC | 23 ms
25,568 KB |
testcase_02 | AC | 24 ms
25,576 KB |
testcase_03 | AC | 23 ms
21,564 KB |
testcase_04 | AC | 23 ms
25,696 KB |
testcase_05 | AC | 23 ms
23,520 KB |
testcase_06 | AC | 23 ms
23,532 KB |
testcase_07 | AC | 24 ms
25,820 KB |
testcase_08 | AC | 23 ms
21,808 KB |
testcase_09 | AC | 23 ms
21,684 KB |
testcase_10 | AC | 22 ms
23,400 KB |
testcase_11 | AC | 22 ms
23,532 KB |
testcase_12 | AC | 23 ms
25,828 KB |
testcase_13 | AC | 23 ms
23,732 KB |
testcase_14 | AC | 23 ms
25,688 KB |
testcase_15 | AC | 22 ms
23,404 KB |
testcase_16 | AC | 22 ms
25,696 KB |
testcase_17 | AC | 23 ms
25,948 KB |
testcase_18 | AC | 22 ms
23,644 KB |
testcase_19 | AC | 22 ms
21,432 KB |
testcase_20 | AC | 23 ms
23,772 KB |
testcase_21 | AC | 23 ms
21,680 KB |
testcase_22 | AC | 23 ms
23,784 KB |
testcase_23 | AC | 23 ms
23,644 KB |
testcase_24 | AC | 23 ms
23,532 KB |
testcase_25 | AC | 23 ms
25,696 KB |
testcase_26 | AC | 23 ms
25,696 KB |
testcase_27 | AC | 22 ms
23,532 KB |
testcase_28 | AC | 24 ms
25,684 KB |
testcase_29 | AC | 24 ms
25,568 KB |
testcase_30 | AC | 24 ms
23,536 KB |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | AC | 24 ms
23,656 KB |
testcase_34 | AC | 24 ms
21,560 KB |
testcase_35 | AC | 24 ms
23,536 KB |
testcase_36 | AC | 23 ms
23,528 KB |
testcase_37 | AC | 24 ms
25,436 KB |
testcase_38 | AC | 24 ms
25,696 KB |
testcase_39 | AC | 23 ms
23,660 KB |
testcase_40 | AC | 24 ms
23,784 KB |
testcase_41 | AC | 24 ms
23,520 KB |
testcase_42 | AC | 24 ms
25,572 KB |
testcase_43 | RE | - |
testcase_44 | AC | 24 ms
23,272 KB |
testcase_45 | AC | 24 ms
23,536 KB |
testcase_46 | RE | - |
testcase_47 | AC | 24 ms
23,728 KB |
testcase_48 | RE | - |
testcase_49 | RE | - |
testcase_50 | RE | - |
testcase_51 | AC | 24 ms
23,656 KB |
testcase_52 | RE | - |
testcase_53 | RE | - |
testcase_54 | AC | 24 ms
25,824 KB |
testcase_55 | AC | 23 ms
23,524 KB |
testcase_56 | AC | 24 ms
25,576 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; long minus = long.Parse(Reader.ReadLine()); long take1 = long.Parse(Reader.ReadLine()); long take2 = long.Parse(Reader.ReadLine()); long take3 = long.Parse(Reader.ReadLine()); long ans = -1; // 真ん中を減らす場合 long ret = this.GetAns1(take1, take2, take3, minus); if(ret >= 0) { ans = ret; } ret = this.GetAns2(take1, take2, take3, minus); if(ret >= 0) { if(ans == -1) { ans = ret; } else { ans = Math.Min(ans, ret); } } Console.WriteLine(ans); } private long GetAns2(long take1, long take2, long take3, long minus) { // 真ん中が引っ込む場合 long tmp1 = take1; long tmp2 = take2; long tmp3 = take3; long ret = 0; if(tmp1 == tmp3) { if(tmp1 == 0) { return -1; } tmp1 = Math.Max(0, tmp1 - minus); ret++; } long times = (tmp2 - Math.Min(tmp1,tmp3)) / minus + 1; tmp2 = Math.Max(0, tmp2 - times * minus); ret += times; if(tmp2 == tmp1 || tmp2 == tmp3) { if(tmp2 == 0) { return -1; } else { tmp2 = Math.Max(0, tmp2 - minus); ret++; } } return ret; } private long GetAns1(long take1, long take2, long take3, long minus) { // 最初から揃っている場合 if(take1 != take2 && take2 != take3 && take3 != take1) { if(take2 > Math.Max(take1, take3)) { return 0; } if(take2 < Math.Min(take1, take3)) { return 0; } } // 真ん中が出る場合 long tmp1 = take1; long tmp2 = take2; long tmp3 = take3; long ret = 0; if(tmp1 >= tmp2) { long times = (take1 - take2) / minus + 1; ret += times; tmp1 = Math.Max(0, tmp1 - (times * minus)); } if(tmp3 >= tmp2) { long times = (take3 - take2) / minus + 1; ret += times; tmp3 = Math.Max(0, tmp3 - (times * minus)); } if(tmp1 == tmp3) { if(tmp1 == 0) { return -1; } else { ret += 1; } } return ret; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 1000000000 1000000000 1000000000 1000000000 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }