結果
| 問題 |
No.951 【本日限定】1枚頼むともう1枚無料!
|
| コンテスト | |
| ユーザー |
fgwiebfaoish
|
| 提出日時 | 2019-12-27 19:32:26 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,071 bytes |
| コンパイル時間 | 1,113 ms |
| コンパイル使用メモリ | 110,208 KB |
| 実行使用メモリ | 20,952 KB |
| 最終ジャッジ日時 | 2024-10-09 05:10:19 |
| 合計ジャッジ時間 | 21,906 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 WA * 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.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 c=new int[s[0]+1];
var dp=new int[2][][];
dp[0]=new int[][]{new int[s[1]+1],new int[s[1]+1]};
dp[1]=new int[][]{new int[s[1]+1],new int[s[1]+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][0][0]=dp[1][0][0]=dp[0][1][0]=dp[1][1][0]=1;
for(int i = 1;i<=s[0];i++) {
for(int j = 0;j<2;j++) {
for(int k = s[1];k>=0;k--) {
if(j==0){
if(dp[(i&1)^1][j^1][k]>0){
dp[i&1][j][k]=Max(dp[i&1][j][k],dp[(i&1)^1][j^1][k]+a[i][1]);
}
}
else{
if(k>=a[i][0]&&dp[(i&1)^1][j^1][k-a[i][0]]>0){
dp[i&1][j][k]=Max(dp[i&1][j][k],dp[(i&1)^1][j^1][k-a[i][0]]+a[i][1]);
}
dp[i&1][j][k]=Max(dp[i&1][j][k],dp[(i&1)^1][j][k]);
}
}
}
dp[i&1][1][0]=1;
}
Console.WriteLine("{0}",Max(dp[0][1].Max(),dp[1][1].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;}
}
fgwiebfaoish