結果
| 問題 | No.54 Happy Hallowe'en |
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2015-10-05 11:14:09 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 300 ms / 5,000 ms |
| + 491µs | |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 1,648 ms |
| コンパイル使用メモリ | 88,348 KB |
| 実行使用メモリ | 49,056 KB |
| 最終ジャッジ日時 | 2026-09-18 19:11:49 |
| 合計ジャッジ時間 | 5,698 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
}
}
ぴろず