結果

問題 No.54 Happy Hallowe'en
ユーザー kuuso1kuuso1
提出日時 2014-10-31 00:38:19
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,559 bytes
コンパイル時間 2,342 ms
コンパイル使用メモリ 105,268 KB
実行使用メモリ 53,180 KB
最終ジャッジ日時 2023-08-28 23:33:46
合計ジャッジ時間 18,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
24,420 KB
testcase_01 AC 61 ms
20,312 KB
testcase_02 AC 62 ms
22,408 KB
testcase_03 AC 62 ms
20,320 KB
testcase_04 AC 1,770 ms
42,344 KB
testcase_05 AC 3,164 ms
44,552 KB
testcase_06 AC 4,719 ms
44,768 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Array.Sort(P,(x,y)=>x.T>y.T?1:x.T<y.T?-1:0);
		
		HashSet<int>[] H=new HashSet<int>[2];
		H[0]=new HashSet<int>();
		H[0].Add(0);

		int now=0;
		int next=1;
		
		for(int i=0;i<N;i++){
			now=i%2;
			next=1-now;
			
			H[next]=new HashSet<int>();
			foreach(int v in H[now]){
//Console.WriteLine("{0} {1}",i,v);
				if(v<P[i].T){
					H[next].Add(v+P[i].V);
				}
				H[next].Add(v);
			}
		}
		
		int max=0;
		foreach(int k in H[next]){
			max=Math.Max(max,k);
		}
		Console.WriteLine(max);
		
	}
	int N;
	Pair[] P;
	public Sol(){
		N=ri();
		P=new Pair[N];
		for(int i=0;i<N;i++){
			P[i]=new Pair(ria());
		}
	}

	class Pair{
		public int V;
		public int T;
		public Pair(int[] in_){
			V=in_[0];T=in_[1];
		}
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0