QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#453895 | #8768. Arrested Development | ucup-team173# | WA | 7ms | 42668kb | C++20 | 762b | 2024-06-24 14:32:48 | 2024-06-24 14:32:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAX = 5e6 + 5;
int f[2][MAX];
int main() {
int n;
cin >> n;
vector<int> a(n), b(n);
int tot = 0;
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
memset(f, 0x3f, sizeof(f));
f[1][0] = 0;
for (int i = 0; i < n; i++) {
memset(f[i & 1], 0x3f, sizeof(f[i & 1]));
for (int j = 0; j <= tot; j++) {
f[i & 1][j] = min(f[~i & 1][j] + b[i], f[i & 1][j]);
f[i & 1][j + a[i]] = min(f[~i & 1][j], f[i & 1][j + a[i]]);
}
tot += a[i];
}
int ans = 1e9;
for (int i = 0; i < tot; i++) {
ans = min(ans, max(i, f[~n & 1][i]));
}
cout << ans << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 7ms
memory: 42668kb
input:
4 100 1 1 90 1 20 1 20
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 42564kb
input:
2 314 1 592 6
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 4ms
memory: 42640kb
input:
1 1 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 42560kb
input:
1 100000 1
output:
1
result:
ok single line: '1'
Test #5:
score: -100
Wrong Answer
time: 3ms
memory: 42636kb
input:
1 1 100000
output:
100000
result:
wrong answer 1st lines differ - expected: '1', found: '100000'