QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#446223 | #8781. Element-Wise Comparison | ando | WA | 53ms | 140092kb | C++20 | 901b | 2024-06-17 02:02:15 | 2024-06-17 02:02:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5 + 10, INF = 1e9;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n; cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
vector<vector<int>> dp(n + 1, vector<int>(5e6 + 1, INF));
dp[0][0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= 5e6; j++) {
dp[i][j] = min(dp[i][j], dp[i - 1][j] + b[i]);
if (j >= a[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i]]);
}
}
int mi = INF;
for (int i = 0; i <= 5e6; i++) {
mi = min(mi, max(dp[n][i], i));
}
cout << mi;
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 53ms
memory: 140092kb
input:
5 3 5 2 1 3 4
output:
5
result:
wrong answer expected '0', found '5'