結果
| 問題 | No.951 【本日限定】1枚頼むともう1枚無料! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-17 03:10:53 |
| 言語 | D (dmd 2.111.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 949 bytes |
| 記録 | |
| コンパイル時間 | 839 ms |
| コンパイル使用メモリ | 124,224 KB |
| 実行使用メモリ | 739,696 KB |
| 最終ジャッジ日時 | 2024-06-22 03:41:35 |
| 合計ジャッジ時間 | 10,670 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 1 MLE * 1 -- * 30 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;
void main() {
auto s = readln.split.map!(to!int);
auto N = s[0];
auto M = s[1];
auto A = iota(N).map!(_ => readln.split.map!(to!int).array).array;
A.sort!"a[0] > b[0]";
auto dp = new int[][][](N+1, M+1, 2);
foreach (i; 0..N+1) foreach (j; 0..M+1) dp[i][j][1] = -(1 << 29);
foreach (i; 0..N) foreach (j; 0..M+1) {
int p = A[i][0];
int d = A[i][1];
dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][0]);
dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][1]);
if (p + j <= M) dp[i+1][j+p][1] = max(dp[i+1][j+p][1], dp[i][j][0] + d);
dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][1] + d);
}
int ans = 0;
foreach (j; 0..M+1) foreach (k; 0..2) ans = max(ans, dp[N][j][k]);
ans.writeln;
}