結果
| 問題 |
No.2492 Knapsack Problem?
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2023-10-06 21:51:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 216 ms / 2,000 ms |
| コード長 | 480 bytes |
| コンパイル時間 | 3,423 ms |
| コンパイル使用メモリ | 74,660 KB |
| 実行使用メモリ | 56,692 KB |
| 最終ジャッジ日時 | 2024-07-26 16:01:02 |
| 合計ジャッジ時間 | 6,344 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] v = new int[n];
int[] w = new int[n];
for (int i = 0; i < n; i++) {
v[i] = sc.nextInt();
w[i] = sc.nextInt();
}
sc.close();
int ans = -1;
for (int i = 0; i < n; i++) {
if (w[i] <= m) {
ans = Math.max(ans, v[i]);
}
}
System.out.println(ans);
}
}
ks2m