結果

問題 No.771 しおり
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2020-01-22 10:24:35
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 2,611 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 109,664 KB
実行使用メモリ 59,940 KB
最終ジャッジ日時 2023-09-29 13:00:16
合計ジャッジ時間 10,302 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 448 ms
57,904 KB
testcase_01 AC 84 ms
25,676 KB
testcase_02 AC 51 ms
21,764 KB
testcase_03 AC 53 ms
21,524 KB
testcase_04 AC 58 ms
23,568 KB
testcase_05 AC 55 ms
21,608 KB
testcase_06 AC 55 ms
23,616 KB
testcase_07 AC 52 ms
21,620 KB
testcase_08 AC 52 ms
23,768 KB
testcase_09 AC 50 ms
23,716 KB
testcase_10 AC 50 ms
21,508 KB
testcase_11 AC 50 ms
21,560 KB
testcase_12 AC 49 ms
21,492 KB
testcase_13 AC 50 ms
21,612 KB
testcase_14 AC 52 ms
21,628 KB
testcase_15 AC 49 ms
21,536 KB
testcase_16 AC 50 ms
23,620 KB
testcase_17 AC 50 ms
21,660 KB
testcase_18 AC 49 ms
23,504 KB
testcase_19 AC 50 ms
21,564 KB
testcase_20 AC 51 ms
23,700 KB
testcase_21 AC 51 ms
21,564 KB
testcase_22 AC 52 ms
25,620 KB
testcase_23 AC 50 ms
21,588 KB
testcase_24 AC 49 ms
19,584 KB
testcase_25 AC 232 ms
39,600 KB
testcase_26 AC 57 ms
21,516 KB
testcase_27 AC 87 ms
23,616 KB
testcase_28 AC 129 ms
32,108 KB
testcase_29 AC 85 ms
25,768 KB
testcase_30 AC 452 ms
57,872 KB
testcase_31 AC 449 ms
59,940 KB
testcase_32 AC 60 ms
21,596 KB
testcase_33 AC 444 ms
57,840 KB
testcase_34 AC 447 ms
57,820 KB
testcase_35 AC 57 ms
23,572 KB
testcase_36 AC 50 ms
21,616 KB
testcase_37 AC 52 ms
21,592 KB
testcase_38 AC 58 ms
21,520 KB
testcase_39 AC 52 ms
21,440 KB
testcase_40 AC 232 ms
43,656 KB
testcase_41 AC 449 ms
57,892 KB
testcase_42 AC 448 ms
59,936 KB
testcase_43 AC 85 ms
23,672 KB
testcase_44 AC 449 ms
59,928 KB
testcase_45 AC 451 ms
57,968 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Arr(n,()=>sc.Ia);
		int m=1<<n;
		var dp=new int[m][];
		dp[0]=new int[n];
		for(int i = 1;i<m;i++) {
			dp[i]=new int[n];
			for(int j = 0;j<n;j++) {
				if((i&(1<<j))!=0&&i!=(1<<j)){
					dp[i][j]=int.MaxValue;
					for(int k = 0;k<n;k++) {
						if((i&(1<<k))!=0&&j!=k){
							dp[i][j]=Min(dp[i][j],Max(dp[i-(1<<j)][k],a[k][1]-a[k][0]+a[j][0]));
						}
					}
				}
			}
		}
		Console.WriteLine("{0}",dp[m-1].Min());
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}
0