Submission #1174387
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Globalization; using System.Diagnostics; class Myon { public Myon() { } public static int Main() { new Myon().calc(); return 0; } Scanner cin; int D; int T; int[] C; int[] A; const int MaxTurn = 1000; const int MaxBox = 8; //A問題 public void calc() { cin = new Scanner(); for (int i = 0; i < MaxTurn; i++) { D = cin.nextInt(); T = cin.nextInt(); C = new int[MaxBox]; A = new int[MaxBox]; for (int j = 0; j < MaxBox; j++) { C[j] = cin.nextInt(); } for (int j = 0; j < MaxBox; j++) { A[j] = cin.nextInt(); } if (D >= 30) { int[] sell = sellcheck(); if (sell.Length > 0) { Console.WriteLine("sell {0} {1}", sell.Length, string.Join(" ", sell)); continue; } if(T >= 2) { int needfill = needFillCheck(getPreArray()); if (needfill != -1) { Console.WriteLine("fill {0}", needfill); continue; } } if (T >= 3) { int needfill = needFillCheck2(getPreArray()); if (needfill != -1) { Console.WriteLine("fill {0}", needfill); continue; } } int fill = fillcheck(); if (fill != -1) { Console.WriteLine("fill {0}", fill); continue; } int low = lowcheck(); if (low != -1) { Console.WriteLine("change {0}", low); continue; } Console.WriteLine("pass"); } else { int low = lowcheck(); if (low != -1) { Console.WriteLine("change {0}", low); continue; } int fill = fillcheck(); if (fill != -1) { Console.WriteLine("fill {0}", fill); continue; } Console.WriteLine("pass"); } } } int[] pre; const int M = 100; int lowcheck() { int ans = -1; int border = 5; for (int i = 0; i < MaxBox; i++) { if(C[i] < border) { border = C[i]; ans = i + 1; } } return ans; } int needFillCheck(int[] pre) { for (int j = 0; j < MaxBox; j++) { if (A[j] == 0 && pre[D - C[j]] != -1) return j + 1; } return -1; } int needFillCheck2(int[] pre) { for (int j = 0; j < MaxBox; j++) { for (int k = 0; k < MaxBox; k++) { if (A[j] == 0 && A[k] == 0 && pre[D - C[j] - C[k]] != -1) return j + 1; } } return -1; } int fillcheck() { int ans = -1; int maxSize = 0; for (int j = 0; j < MaxBox; j++) { if (A[j] == 0 && maxSize < C[j]) { ans = j + 1; maxSize = C[j]; } } return ans; } int[] sellcheck() { int[] pre = getPreArray(); if(pre[D] == -1) { return new int[0]; } List<int> ans = new List<int>(); int now = D; while(now != 0) { ans.Add(pre[now] + 1); now -= A[pre[now]]; } return ans.ToArray(); } int[] getPreArray() { int[] pre = new int[M]; for (int i = 0; i < M; i++) { pre[i] = -1; } pre[0] = 0; for (int i = 0; i < MaxBox; i++) { if (A[i] == 0) continue; for (int j = M - 1; j >= 0; j--) { if (pre[j] != -1 && pre[j + A[i]] == -1) pre[j + A[i]] = i; } } return pre; } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string next() { if (i < s.Length) return s[i++]; string st = Console.ReadLine(); while (st == "") st = Console.ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return s[i++]; } public int nextInt() { return int.Parse(next()); } public long nextLong() { return long.Parse(next()); } public double nextDouble() { return double.Parse(next()); } }
Submission Info
Submission Time | |
---|---|
Task | B - 日本橋大渋滞 |
User | chokudai |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 5551 Byte |
Status | RE |
Exec Time | 23 ms |
Memory | 12768 KB |
Judge Result
Set Name | test_01 | test_02 | test_03 | test_04 | test_05 | test_06 | test_07 | test_08 | test_09 | test_10 | test_11 | test_12 | test_13 | test_14 | test_15 | test_16 | test_17 | test_18 | test_19 | test_20 | test_21 | test_22 | test_23 | test_24 | test_25 | test_26 | test_27 | test_28 | test_29 | test_30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | 0 / 50000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Status |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set Name | Test Cases |
---|---|
test_01 | subtask_01_01.txt |
test_02 | subtask_01_02.txt |
test_03 | subtask_01_03.txt |
test_04 | subtask_01_04.txt |
test_05 | subtask_01_05.txt |
test_06 | subtask_01_06.txt |
test_07 | subtask_01_07.txt |
test_08 | subtask_01_08.txt |
test_09 | subtask_01_09.txt |
test_10 | subtask_01_10.txt |
test_11 | subtask_01_11.txt |
test_12 | subtask_01_12.txt |
test_13 | subtask_01_13.txt |
test_14 | subtask_01_14.txt |
test_15 | subtask_01_15.txt |
test_16 | subtask_01_16.txt |
test_17 | subtask_01_17.txt |
test_18 | subtask_01_18.txt |
test_19 | subtask_01_19.txt |
test_20 | subtask_01_20.txt |
test_21 | subtask_01_21.txt |
test_22 | subtask_01_22.txt |
test_23 | subtask_01_23.txt |
test_24 | subtask_01_24.txt |
test_25 | subtask_01_25.txt |
test_26 | subtask_01_26.txt |
test_27 | subtask_01_27.txt |
test_28 | subtask_01_28.txt |
test_29 | subtask_01_29.txt |
test_30 | subtask_01_30.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask_01_01.txt | RE | 21 ms | 8672 KB |
subtask_01_02.txt | RE | 23 ms | 10720 KB |
subtask_01_03.txt | RE | 21 ms | 10720 KB |
subtask_01_04.txt | RE | 21 ms | 10720 KB |
subtask_01_05.txt | RE | 23 ms | 10720 KB |
subtask_01_06.txt | RE | 21 ms | 12768 KB |
subtask_01_07.txt | RE | 21 ms | 10592 KB |
subtask_01_08.txt | RE | 23 ms | 10720 KB |
subtask_01_09.txt | RE | 23 ms | 10720 KB |
subtask_01_10.txt | RE | 23 ms | 12768 KB |
subtask_01_11.txt | RE | 21 ms | 12640 KB |
subtask_01_12.txt | RE | 22 ms | 8672 KB |
subtask_01_13.txt | RE | 21 ms | 10592 KB |
subtask_01_14.txt | RE | 20 ms | 10592 KB |
subtask_01_15.txt | RE | 21 ms | 12640 KB |
subtask_01_16.txt | RE | 20 ms | 10720 KB |
subtask_01_17.txt | RE | 20 ms | 8672 KB |
subtask_01_18.txt | RE | 20 ms | 10720 KB |
subtask_01_19.txt | RE | 21 ms | 10720 KB |
subtask_01_20.txt | RE | 23 ms | 10720 KB |
subtask_01_21.txt | RE | 21 ms | 10720 KB |
subtask_01_22.txt | RE | 21 ms | 10720 KB |
subtask_01_23.txt | RE | 21 ms | 10720 KB |
subtask_01_24.txt | RE | 23 ms | 10720 KB |
subtask_01_25.txt | RE | 21 ms | 8672 KB |
subtask_01_26.txt | RE | 23 ms | 10720 KB |
subtask_01_27.txt | RE | 21 ms | 12768 KB |
subtask_01_28.txt | RE | 21 ms | 10720 KB |
subtask_01_29.txt | RE | 20 ms | 8672 KB |
subtask_01_30.txt | RE | 20 ms | 8672 KB |