提出 #25978865
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < (int)n; i++)
#define REP(i, n) FOR(i, 0, n)
#define REPEQ(i, n) FOR(i, 0, n+1)
#define INF 1000000000
int N, X, Y;
int dp[301][301][301];
int A[301];
int B[301];
int main() {
cin >> N >> X >> Y;
REP(n, N) cin >> A[n] >> B[n];
REPEQ(n, N) REPEQ(x, X) REPEQ(y,Y) dp[n][x][y] = INF;
REPEQ(x, X) REPEQ(y, Y) dp[0][x][y] = INF;
dp[0][0][0] = 0;
REPEQ(n, N-1) REPEQ(x, X) REPEQ(y, Y) {
int xx = min(x+A[n], X);
int yy = min(y+B[n], Y);
dp[n+1][xx][yy] = min(dp[n+1][xx][yy], dp[n][x][y]+1);
dp[n+1][x ][y ] = min(dp[n+1][x ][y ], dp[n][x][y]);
}
cout << (dp[N][X][Y] != INF ? dp[N][X][Y] : -1) << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Strange Lunchbox |
| ユーザ | ryo_ryo66 |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 400 |
| コード長 | 767 Byte |
| 結果 | AC |
| 実行時間 | 140 ms |
| メモリ | 110116 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, example0.txt, example1.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 10 ms | 3488 KiB |
| 001.txt | AC | 2 ms | 3488 KiB |
| 002.txt | AC | 3 ms | 4240 KiB |
| 003.txt | AC | 5 ms | 4056 KiB |
| 004.txt | AC | 127 ms | 109884 KiB |
| 005.txt | AC | 122 ms | 110112 KiB |
| 006.txt | AC | 131 ms | 110076 KiB |
| 007.txt | AC | 123 ms | 109872 KiB |
| 008.txt | AC | 40 ms | 40204 KiB |
| 009.txt | AC | 123 ms | 110048 KiB |
| 010.txt | AC | 4 ms | 4540 KiB |
| 011.txt | AC | 35 ms | 32788 KiB |
| 012.txt | AC | 48 ms | 56228 KiB |
| 013.txt | AC | 124 ms | 109884 KiB |
| 014.txt | AC | 121 ms | 110000 KiB |
| 015.txt | AC | 124 ms | 110116 KiB |
| 016.txt | AC | 125 ms | 110064 KiB |
| 017.txt | AC | 122 ms | 110076 KiB |
| 018.txt | AC | 16 ms | 15472 KiB |
| 019.txt | AC | 34 ms | 32428 KiB |
| 020.txt | AC | 59 ms | 84892 KiB |
| 021.txt | AC | 21 ms | 20564 KiB |
| 022.txt | AC | 56 ms | 65876 KiB |
| 023.txt | AC | 37 ms | 30320 KiB |
| 024.txt | AC | 66 ms | 61576 KiB |
| 025.txt | AC | 8 ms | 7316 KiB |
| 026.txt | AC | 32 ms | 26224 KiB |
| 027.txt | AC | 29 ms | 30336 KiB |
| 028.txt | AC | 5 ms | 5284 KiB |
| 029.txt | AC | 18 ms | 12476 KiB |
| 030.txt | AC | 62 ms | 54956 KiB |
| 031.txt | AC | 70 ms | 70148 KiB |
| 032.txt | AC | 19 ms | 17964 KiB |
| 033.txt | AC | 35 ms | 32276 KiB |
| 034.txt | AC | 86 ms | 87576 KiB |
| 035.txt | AC | 65 ms | 81352 KiB |
| 036.txt | AC | 59 ms | 51244 KiB |
| 037.txt | AC | 91 ms | 82568 KiB |
| 038.txt | AC | 8 ms | 7896 KiB |
| 039.txt | AC | 2 ms | 3812 KiB |
| 040.txt | AC | 5 ms | 6124 KiB |
| 041.txt | AC | 12 ms | 7784 KiB |
| 042.txt | AC | 16 ms | 7604 KiB |
| 043.txt | AC | 10 ms | 7252 KiB |
| 044.txt | AC | 125 ms | 109880 KiB |
| 045.txt | AC | 124 ms | 109712 KiB |
| 046.txt | AC | 140 ms | 110004 KiB |
| 047.txt | AC | 140 ms | 109708 KiB |
| example0.txt | AC | 3 ms | 3572 KiB |
| example1.txt | AC | 3 ms | 3412 KiB |