QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#428368 | #8768. Arrested Development | ucup-team3608# | TL | 1985ms | 206492kb | C++23 | 838b | 2024-06-01 19:07:05 | 2024-06-01 19:07:06 |
Judging History
answer
#include <bits/stdc++.h>
#define st first
#define nd second
using lint = long long;
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr lint linf = 0x3f3f3f3f3f3f3f3f;
using namespace std;
const int ms = 26000000;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin>>n;
vector<int>dp(ms, inf);
vector<int>a(n), b(n);
for(int i=0;i<n;i++) cin>>a[i]>>b[i];
dp[0] = 0;
for(int i=0;i<n;i++){
vector<int>ndp(ms, inf);
for(int j=0;j<ms;j++){
ndp[j] = min(ndp[j], dp[j] + b[i]);
if(j + a[i] < ms) ndp[j+a[i]] = min(ndp[j+a[i]], dp[j]);
}
swap(dp, ndp);
}
int ans = inf;
for(int i=0;i<ms;i++){
ans = min(ans, max(i, dp[i]));
}
cout<<ans<<"\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 272ms
memory: 206332kb
input:
4 100 1 1 90 1 20 1 20
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 109ms
memory: 206408kb
input:
2 314 1 592 6
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 89ms
memory: 206336kb
input:
1 1 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 68ms
memory: 206476kb
input:
1 100000 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 103ms
memory: 206324kb
input:
1 1 100000
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 60ms
memory: 206492kb
input:
1 100000 100000
output:
100000
result:
ok single line: '100000'
Test #7:
score: 0
Accepted
time: 1985ms
memory: 206384kb
input:
50 78681 95291 22639 1538 12119 52253 50430 63757 66133 92826 61048 40069 33506 30382 96049 50134 42895 62735 86943 16955 9667 61843 49647 9320 29082 16909 69601 68436 19892 34306 29822 79462 73262 14568 1693 35040 89757 61888 56993 48750 89611 77773 54159 21067 32520 41091 52501 92770 36530 17589 5...
output:
855897
result:
ok single line: '855897'
Test #8:
score: 0
Accepted
time: 1937ms
memory: 206416kb
input:
50 17109 75621 51243 72763 67210 97483 57809 9601 66344 79911 91593 38930 51920 44188 82765 20595 87230 78655 78390 14375 20216 46782 64273 61631 82422 38207 38700 26994 58768 59731 90891 94282 11999 82480 10537 43098 60805 6845 99773 94421 77415 93587 20930 48902 41915 46679 47122 15869 80233 45051...
output:
970753
result:
ok single line: '970753'
Test #9:
score: 0
Accepted
time: 1937ms
memory: 206368kb
input:
50 2550 81408 11829 4584 2219 81395 29614 56561 26962 68531 75540 50942 71976 48185 86117 3694 94775 69554 39370 54004 17957 6603 34705 52269 74564 42575 37808 32963 88311 94915 59023 58486 56638 83516 40308 82531 34419 58020 34265 75871 57754 49876 36742 68905 3307 55011 17936 35479 19498 754 19244...
output:
754695
result:
ok single line: '754695'
Test #10:
score: -100
Time Limit Exceeded
input:
50 64759 26973 62862 96337 45442 39020 91618 12901 60216 7019 34306 56297 21741 56969 2090 94544 22833 51857 62768 59383 50567 24374 3424 31168 5333 78872 72155 96458 61965 99734 56314 3160 12457 36692 90359 56330 25457 54691 32134 61448 25173 21122 49951 60165 92323 63462 94575 89188 10877 50057 18...
output:
798477