結果
問題 | No.1 道のショートカット |
ユーザー | nokonoko |
提出日時 | 2017-10-03 22:52:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,803 bytes |
コンパイル時間 | 1,219 ms |
コンパイル使用メモリ | 119,432 KB |
実行使用メモリ | 27,864 KB |
最終ジャッジ日時 | 2024-07-08 04:58:07 |
合計ジャッジ時間 | 3,850 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
25,504 KB |
testcase_01 | AC | 29 ms
25,376 KB |
testcase_02 | AC | 30 ms
25,052 KB |
testcase_03 | AC | 31 ms
27,300 KB |
testcase_04 | AC | 30 ms
25,372 KB |
testcase_05 | AC | 29 ms
25,520 KB |
testcase_06 | AC | 30 ms
25,396 KB |
testcase_07 | AC | 29 ms
25,380 KB |
testcase_08 | AC | 34 ms
25,808 KB |
testcase_09 | AC | 34 ms
25,888 KB |
testcase_10 | AC | 35 ms
25,904 KB |
testcase_11 | AC | 37 ms
25,796 KB |
testcase_12 | AC | 35 ms
26,156 KB |
testcase_13 | AC | 36 ms
26,268 KB |
testcase_14 | WA | - |
testcase_15 | RE | - |
testcase_16 | AC | 33 ms
27,664 KB |
testcase_17 | RE | - |
testcase_18 | AC | 29 ms
27,164 KB |
testcase_19 | AC | 28 ms
25,500 KB |
testcase_20 | AC | 33 ms
26,012 KB |
testcase_21 | AC | 34 ms
27,864 KB |
testcase_22 | AC | 30 ms
25,372 KB |
testcase_23 | WA | - |
testcase_24 | AC | 37 ms
25,752 KB |
testcase_25 | AC | 34 ms
25,764 KB |
testcase_26 | AC | 33 ms
26,036 KB |
testcase_27 | AC | 35 ms
25,628 KB |
testcase_28 | RE | - |
testcase_29 | AC | 34 ms
23,732 KB |
testcase_30 | AC | 32 ms
25,628 KB |
testcase_31 | AC | 36 ms
26,160 KB |
testcase_32 | AC | 35 ms
25,884 KB |
testcase_33 | AC | 34 ms
25,712 KB |
testcase_34 | AC | 36 ms
26,144 KB |
testcase_35 | AC | 34 ms
25,716 KB |
testcase_36 | AC | 34 ms
25,884 KB |
testcase_37 | AC | 33 ms
23,480 KB |
testcase_38 | AC | 29 ms
25,632 KB |
testcase_39 | AC | 33 ms
25,772 KB |
testcase_40 | AC | 33 ms
25,820 KB |
testcase_41 | AC | 35 ms
25,756 KB |
testcase_42 | RE | - |
testcase_43 | RE | - |
コンパイルメッセージ
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; using System.Text; using System.Collections.Generic; using STR = System.String; using INT = System.Int32; using DEC = System.Double; class Program { public static IO IO = new IO(); public struct DATA { public INT N; public INT T; public INT Y; public INT M; public DATA(INT n, INT t, INT y, INT m) { N = n; T = t; Y = y; M =m; } public bool SAME(DATA t) { return T == t.T && Y == t.Y; } } static void Main(string[] args) { INT n = IO.I(); INT c = IO.I(); INT v = IO.I(); INT[] s = IO.I(' '); INT[] t = IO.I(' '); INT[] y = IO.I(' '); INT[] m = IO.I(' '); INT[] tmin = new INT[v]; Dictionary<INT, List<DATA>> data = new Dictionary<int, List<DATA>>(); QUEUE<DATA> que = new QUEUE<DATA>(v); for (int i = 0; i < v; i++) { if (!data.Keys.Contains(s[i])) { data[s[i]] = new List<DATA>(); } data[s[i]].Add(new DATA(i, t[i], y[i], m[i])); tmin[i] = INT.MaxValue; } for (int i = 0; i < data[1].Count(); i++) { que.PUSH(data[1][i]); } while (que.SIZE() != 0) { DATA x = que.POP(); if ((x.Y <= c) && (tmin[x.T - 1] > x.M)) { tmin[x.T - 1] = x.M; } if (data.ContainsKey(x.T)) { for (int i = 0; i < data[x.T].Count(); i++) { DATA buf = data[x.T][i]; if ((buf.Y + x.Y <= c) && (tmin[buf.T - 1] > buf.M + x.M)) { que.PUSH(new DATA(buf.N, buf.T, buf.Y + x.Y, buf.M + x.M)); } } } } INT o = -1; if (tmin[n - 1] != INT.MaxValue) { o = tmin[n - 1]; } IO.W(o); IO.F(); } } public class QUEUE<T> { protected INT m; private INT s, e, c; private T[] q; public QUEUE(INT max) { m = max; q = new T[m]; CLEAR(); } public void CLEAR() { e = 0; s = 0; c = 0; } public INT SIZE() { return c; } public T TOP() { return q[s]; } public T POP() { T r = q[s++]; s %= m; c--; return r; } public virtual void PUSH(T v) { q[e++] = v; e %= m; c++; } public bool EMPTY() { return SIZE() == 0; } } public class IO { private const int WMAX = 1000; private StringBuilder SB = new StringBuilder(); private T R<T>(Func<STR, T> f) { return f(Console.ReadLine()); } private T[] R<T>(Func<STR, T> f, char c) { return S().Split(c).Select(f).ToArray(); } private T[] R<T>(Func<STR, T> f, INT l) { T[] r = new T[l]; for (INT i = 0; i < l; i++) { r[i] = R(f); } return r; } private T[][] R<T>(Func<STR, T> f, INT l, char c) { T[][] r = new T[l][]; for (INT i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; } private void W<T>(Func<T, STR> f, T v, bool lf = true) { SB.Append(f(v)); if (lf) { SB.Append('\n'); } if (SB.Length >= WMAX) { F(); } } public STR S() { return R(s => s); } public STR[] S(char c) { return R(s => s, c); } public STR[] S(INT l) { return R(s => s, l); } public STR[][] S(INT l, char c) { return R(s => s, l, c); } public INT I() { return R(INT.Parse); } public INT[] I(char c) { return R(INT.Parse, c); } public INT[] I(INT l) { return R(INT.Parse, l); } public INT[][] I(INT l, char c) { return R(INT.Parse, l, c); } public DEC D() { return R(DEC.Parse); } public DEC[] D(char c) { return R(DEC.Parse, c); } public DEC[] D(INT l) { return R(DEC.Parse, l); } public DEC[][] D(INT l, char c) { return R(DEC.Parse, l, c); } public void W(object s, bool lf = true) { W(v => v.ToString(), s, lf); } public void F() { Console.Write(SB); SB.Length = 0; } }