結果
問題 | No.1583 Building Blocks |
ユーザー | fgwiebfaoish |
提出日時 | 2021-07-03 21:42:48 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 3,443 bytes |
コンパイル時間 | 2,723 ms |
コンパイル使用メモリ | 114,428 KB |
実行使用メモリ | 26,076 KB |
最終ジャッジ日時 | 2024-09-14 02:52:00 |
合計ジャッジ時間 | 3,757 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
24,032 KB |
testcase_01 | AC | 26 ms
21,940 KB |
testcase_02 | AC | 26 ms
23,772 KB |
testcase_03 | AC | 26 ms
21,940 KB |
testcase_04 | AC | 27 ms
23,700 KB |
testcase_05 | AC | 27 ms
24,088 KB |
testcase_06 | AC | 27 ms
23,700 KB |
testcase_07 | AC | 28 ms
24,032 KB |
testcase_08 | AC | 26 ms
21,940 KB |
testcase_09 | AC | 28 ms
23,956 KB |
testcase_10 | AC | 27 ms
24,220 KB |
testcase_11 | AC | 26 ms
23,904 KB |
testcase_12 | AC | 27 ms
21,556 KB |
testcase_13 | AC | 28 ms
22,064 KB |
testcase_14 | AC | 27 ms
23,824 KB |
testcase_15 | AC | 27 ms
25,696 KB |
testcase_16 | AC | 28 ms
23,956 KB |
testcase_17 | AC | 28 ms
23,824 KB |
testcase_18 | AC | 26 ms
23,980 KB |
testcase_19 | AC | 30 ms
25,996 KB |
testcase_20 | AC | 27 ms
22,072 KB |
testcase_21 | AC | 28 ms
23,700 KB |
testcase_22 | AC | 27 ms
23,780 KB |
testcase_23 | AC | 27 ms
24,036 KB |
testcase_24 | AC | 28 ms
24,204 KB |
testcase_25 | AC | 26 ms
23,984 KB |
testcase_26 | AC | 29 ms
24,024 KB |
testcase_27 | AC | 27 ms
24,212 KB |
testcase_28 | AC | 30 ms
24,036 KB |
testcase_29 | AC | 29 ms
25,828 KB |
testcase_30 | AC | 27 ms
24,164 KB |
testcase_31 | AC | 27 ms
21,940 KB |
testcase_32 | AC | 27 ms
23,964 KB |
testcase_33 | AC | 28 ms
23,828 KB |
testcase_34 | AC | 26 ms
23,576 KB |
testcase_35 | AC | 27 ms
25,872 KB |
testcase_36 | AC | 28 ms
23,924 KB |
testcase_37 | AC | 27 ms
25,876 KB |
testcase_38 | AC | 26 ms
24,156 KB |
testcase_39 | AC | 26 ms
26,076 KB |
testcase_40 | AC | 27 ms
25,948 KB |
testcase_41 | AC | 27 ms
24,216 KB |
testcase_42 | AC | 26 ms
24,032 KB |
testcase_43 | AC | 27 ms
23,828 KB |
testcase_44 | AC | 27 ms
24,108 KB |
testcase_45 | AC | 27 ms
25,992 KB |
コンパイルメッセージ
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; using System.Threading; using System.Runtime.CompilerServices; using System.Diagnostics; //using nint=System.Int32; static class Program{ const int mod=(int)1e9+7; static void Main(){ Sc sc=new Sc(); var n=sc.I; var a=new long[n][]; var dp=new long[n+1]; for(int i = 0;i<n;i++) { a[i]=sc.La; dp[i+1]=-1; } Array.Sort(a,(u,v)=>(v[1]-u[0]).CompareTo(u[1]-v[0])); dp[0]=long.MaxValue>>1; for(int i = 0;i<n;i++) { for(int j = i+1;j>0;j--) { if(dp[j-1]<0){continue;} dp[j]=Max(dp[j],Min(dp[j-1]-a[i][0],a[i][1])); } } for(int i = n;i>=0;i--) { if(dp[i]>=0){ Console.WriteLine("{0}",i); return; } } } } 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(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);} public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);} public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}} public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);} public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);} public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}} public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.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;} public (T,T) Tp2<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]));} public (T,T,T) Tp3<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]));} public (T,T,T,T) Tp4<T>(){var s=Console.ReadLine().Split();return (Ct<T>(s[0]),Ct<T>(s[1]),Ct<T>(s[2]),Ct<T>(s[3]));} public (T1,T2) Tp2<T1,T2>(){var s=Console.ReadLine().Split();return (Ct<T1>(s[0]),Ct<T2>(s[1]));} public (T1,T1,T2) Tp3<T1,T2>(){var s=Console.ReadLine().Split();return (Ct<T1>(s[0]),Ct<T1>(s[1]),Ct<T2>(s[2]));} private T Ct<T>(string s){return (T)Convert.ChangeType(s,typeof(T));} }