結果
| 問題 | No.54 Happy Hallowe'en |
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2015-10-05 11:14:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 544 ms / 5,000 ms |
| コード長 | 792 bytes |
| コンパイル時間 | 3,222 ms |
| コンパイル使用メモリ | 79,900 KB |
| 実行使用メモリ | 48,292 KB |
| 最終ジャッジ日時 | 2024-10-15 17:13:49 |
| 合計ジャッジ時間 | 8,589 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static int MAX = 20000;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
House[] h = new House[n];
for(int i=0;i<n;i++) {
int v = sc.nextInt();
int t = sc.nextInt();
h[i] = new House(v,t);
}
Arrays.sort(h,(a,b)->Integer.compare(a.v + a.t, b.v + b.t));
boolean[] dp = new boolean[MAX+1];
dp[0] = true;
for(int i=0;i<n;i++) {
for(int j=h[i].t-1;j>=0;j--) {
if (dp[j]) {
dp[j+h[i].v] = true;
}
}
}
int max = 0;
for(int i=0;i<=MAX;i++) {
if (dp[i]) {
max = i;
}
}
System.out.println(max);
}
static class House {
int v,t;
public House(int v,int t) {
this.v = v;
this.t = t;
}
}
}
ぴろず