結果
問題 | No.825 賢いお買い物 |
ユーザー | ひばち |
提出日時 | 2019-05-03 22:00:40 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,029 bytes |
コンパイル時間 | 1,282 ms |
コンパイル使用メモリ | 120,660 KB |
実行使用メモリ | 27,552 KB |
最終ジャッジ日時 | 2024-06-10 06:38:20 |
合計ジャッジ時間 | 3,153 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 33 ms
27,352 KB |
testcase_01 | AC | 34 ms
25,572 KB |
testcase_02 | AC | 33 ms
27,236 KB |
testcase_03 | AC | 33 ms
25,136 KB |
testcase_04 | AC | 33 ms
25,132 KB |
testcase_05 | WA | - |
testcase_06 | AC | 33 ms
27,552 KB |
testcase_07 | AC | 33 ms
23,348 KB |
testcase_08 | AC | 34 ms
25,516 KB |
testcase_09 | AC | 32 ms
23,348 KB |
testcase_10 | AC | 32 ms
25,000 KB |
testcase_11 | AC | 33 ms
23,220 KB |
testcase_12 | AC | 35 ms
25,384 KB |
testcase_13 | AC | 33 ms
27,292 KB |
testcase_14 | AC | 33 ms
25,252 KB |
testcase_15 | AC | 34 ms
27,296 KB |
testcase_16 | AC | 33 ms
25,252 KB |
testcase_17 | AC | 33 ms
25,268 KB |
testcase_18 | AC | 34 ms
23,344 KB |
testcase_19 | AC | 34 ms
25,568 KB |
testcase_20 | AC | 34 ms
25,508 KB |
testcase_21 | AC | 34 ms
25,260 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.Linq; using static System.Console; using static System.Convert; using static System.Math; //using Debug; //using static System.Globalization.CultureInfo; using System.Text; class Program { static void Main(string[] args) { Solve(); //WriteLine(Solve()); } static void Solve() { var abc = Input.ar; var val = abc[0] + 10 * abc[1]; var e = new List<Pair<int, int, int>>() { new Pair<int, int, int>(0, 0, 0) }; for (var i = 0; i < abc[0]; i++) e.Add(new Pair<int, int, int>(i+1,i+1,0));var c = e.Count; for (var i = 0; i < c; i++) for (var j = 0; j < abc[1]; j++) e.Add(new Pair<int, int, int>(e[i].v1 + 10 * (j + 1), e[i].v2, j + 1)); var v = e.Where(a => a.v2/10 + a.v3+a.v2%10 == abc[2] && a.v1 != val).Select(a => val - a.v1).OrderBy(a => a).FirstOrDefault(); if (v == 0) WriteLine("Impossible"); else WriteLine(v); } } public class Input { public static string read => ReadLine(); public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse); public static int num => ToInt32(read); public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse); public static long numL => ToInt64(read); public static char[][] gred(int h) => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray(); public static int[][] ar2D(int num) => Enumerable.Repeat(0, num).Select(_ => ar).ToArray(); public static long[][] arL2D(int num) => Enumerable.Repeat(0, num).Select(_ => arL).ToArray(); public static T getValue<T>(string g) { var t = typeof(T); if (t == typeof(int)) return (T)(object)int.Parse(g); if (t == typeof(long)) return (T)(object)long.Parse(g); if (t == typeof(string)) return (T)(object)g; if (t == typeof(char)) return (T)(object)char.Parse(g); if (t == typeof(double)) return (T)(object)double.Parse(g); if (t == typeof(bool)) return (T)(object)bool.Parse(g); return default(T); } public const long Inf = (long)1e18; public const double eps = 1e-6; public const string alfa = "abcdefghijklmnopqrstuvwxyz"; public const int MOD = 1000000007; } public class Pair<T1, T2> : IComparable<Pair<T1, T2>> { public T1 v1 { get; set; } public T2 v2 { get; set; } public Pair() : this(default(T1), default(T2)) { } public Pair(T1 v1, T2 v2) => SetValue(v1, v2); public int CompareTo(Pair<T1, T2> p) { var c = Comparer<T1>.Default.Compare(v1, p.v1); if (c == 0) c = Comparer<T2>.Default.Compare(v2, p.v2); return c; } public void SetValue(T1 v1,T2 v2) { this.v1 = v1;this.v2 = v2; } public static Pair<T1, T2> makePair() { var r = ReadLine().Split(' '); return new Pair<T1, T2>(Input.getValue<T1>(r[0]), Input.getValue<T2>(r[1])); } public override string ToString() => $"{v1.ToString()} {v2.ToString()}"; } public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> { public T3 v3 { get; set; } public Pair() : base() => v3 = default(T3); public Pair(T1 v1,T2 v2,T3 v3):base() => SetValue(v1, v2, v3); public int CompareTo(Pair<T1, T2, T3> p) { var c = base.CompareTo(p); if (c == 0) c = Comparer<T3>.Default.Compare(v3, p.v3); return c; } public void SetValue(T1 v1, T2 v2, T3 v3) { base.SetValue(v1, v2); this.v3 = v3; } public new static Pair<T1, T2, T3> makePair() { var r = ReadLine().Split(' '); return new Pair<T1, T2, T3>(Input.getValue<T1>(r[0]), Input.getValue<T2>(r[1]), Input.getValue<T3>(r[2])); } public override string ToString() => $"{base.ToString()} {v3.ToString()}"; }