結果
| 問題 |
No.19 ステージの選択
|
| ユーザー |
14番
|
| 提出日時 | 2016-04-01 00:28:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,732 bytes |
| コンパイル時間 | 4,297 ms |
| コンパイル使用メモリ | 114,224 KB |
| 実行使用メモリ | 34,812 KB |
| 最終ジャッジ日時 | 2024-10-02 08:43:41 |
| 合計ジャッジ時間 | 8,037 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 TLE * 1 -- * 19 |
コンパイルメッセージ
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;
public class Program
{
public void Proc(){
Reader.IsDebug = false;
int stageCount = int.Parse(Reader.ReadLine());
List<int> targetList = new List<int>();
for(int i=0; i<stageCount; i++) {
int[] inpt = Reader.GetInt();
StageList.Add(new Nanido(i+1, inpt[1], inpt[0] * 10));
targetList.Add(i+1);
}
int ans = this.GetAns(targetList);
Console.WriteLine((ans / 10.0).ToString("0.0"));
}
private Dictionary<string, int> dic = new Dictionary<string, int>();
private int GetAns(List<int> target) {
if(target.Count == 0) {
return 0;
}
string key = string.Join<int>("#", target);
if(dic.ContainsKey(key)) {
return dic[key];
}
int ans = int.MaxValue;
for(int i=0; i<target.Count; i++) {
int stage = target[i];
int before = this.StageList[stage - 1].BeforeStage;
int nanido = this.StageList[stage - 1].Value;
if(!target.Contains(before)) {
nanido = nanido / 2;
}
List<int> subList = new List<int>();
subList.AddRange(target);
subList.RemoveAt(i);
ans = Math.Min(ans, GetAns(subList) + nanido);
}
this.dic[key] = ans;
return ans;
}
private List<Nanido> StageList = new List<Nanido>();
public class Nanido {
public int Stage = 0;
public int BeforeStage = 0;
public int Value = 0;
public Nanido(int stageNum, int beforeStage, int nan) {
this.Stage = stageNum;
this.BeforeStage = beforeStage;
this.Value = nan;
}
}
public static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
class Reader
{
public static bool IsDebug = true;
private static System.IO.StringReader sr;
public static string ReadLine() {
if(IsDebug) {
if(sr == null) {
sr = new System.IO.StringReader(initStr.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
public static int[] GetInt(char delimiter = ' ') {
string[] inpt = ReadLine().Split(delimiter);
int[] ret = new int[inpt.Length];
for(int i=0; i<inpt.Length; i++) {
ret[i] = int.Parse(inpt[i]);
}
return ret;
}
private static string initStr = @"
15
1 2
2 1
3 3
4 6
5 4
6 5
7 5
8 7
9 7
10 7
11 15
12 14
13 15
14 11
15 15
";
}
14番