結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー fgwiebfaoishfgwiebfaoish
提出日時 2019-12-27 13:22:24
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,783 bytes
コンパイル時間 2,834 ms
コンパイル使用メモリ 108,672 KB
実行使用メモリ 121,088 KB
最終ジャッジ日時 2024-04-16 20:52:54
合計ジャッジ時間 19,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
18,944 KB
testcase_01 AC 33 ms
18,944 KB
testcase_02 AC 32 ms
18,944 KB
testcase_03 AC 32 ms
19,072 KB
testcase_04 AC 33 ms
19,200 KB
testcase_05 AC 32 ms
19,200 KB
testcase_06 WA -
testcase_07 AC 33 ms
19,072 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 479 ms
94,976 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 33 ms
19,200 KB
testcase_19 AC 32 ms
19,200 KB
testcase_20 AC 32 ms
19,200 KB
testcase_21 AC 40 ms
20,224 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 617 ms
120,832 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 33 ms
19,072 KB
testcase_31 AC 32 ms
19,200 KB
testcase_32 AC 35 ms
19,712 KB
testcase_33 WA -
testcase_34 AC 42 ms
20,352 KB
testcase_35 AC 613 ms
120,704 KB
testcase_36 AC 610 ms
120,576 KB
testcase_37 AC 659 ms
120,576 KB
testcase_38 AC 659 ms
120,960 KB
testcase_39 WA -
testcase_40 AC 639 ms
121,088 KB
testcase_41 AC 641 ms
120,960 KB
testcase_42 AC 641 ms
120,576 KB
testcase_43 AC 638 ms
120,576 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 473 ms
120,576 KB
testcase_47 AC 475 ms
120,960 KB
testcase_48 AC 475 ms
120,960 KB
testcase_49 AC 473 ms
120,832 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 462 ms
101,120 KB
testcase_53 AC 541 ms
120,576 KB
testcase_54 AC 271 ms
120,704 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 s=sc.Ia;
		var a=new int[s[0]+1][];
		var dp=new int[s[0]+1][];
		a[0]=new int[]{0,0};
		for(int i = 1;i<=s[0];i++) {a[i]=sc.Ia;}
		a=a.OrderBy(x=>x[0]).ThenBy(x=>x[1]).ToArray();
		dp[0]=new int[s[1]+1];
		dp[0][0]=1;
		for(int i = 1;i<=s[0];i++) {
			dp[i]=new int[s[1]+1];
			for(int j = s[1];j>=0;j--) {
				dp[i][j]=dp[i-1][j];
				if(j>=a[i][0]&&dp[i-1][j-a[i][0]]!=0){
					dp[i][j]=Max(dp[i][j],dp[i-1][j-a[i][0]]+a[i][1]);
				}
				if(j>=a[i][0]&&i>=2&&dp[i-2][j-a[i][0]]!=0){
					dp[i][j]=Max(dp[i][j],dp[i-2][j-a[i][0]]+a[i][1]+a[i-1][1]);
				}
			}
		}
		Console.WriteLine("{0}",dp[s[0]].Max()-1);
	}
}

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