QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686441 | #4931. Comic Binge | SanguineChameleon# | ML | 33ms | 258280kb | C++20 | 1.2kb | 2024-10-29 13:08:02 | 2024-10-29 13:08:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define mp make_pair
#define eb emplace_back
#define pb push_back
typedef pair<int,int> pii;
const int mxt = 1e5;
int dp[1005][mxt + 5][2];
int a[1005],b[1005];
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++)cin>>b[i];
int ans=1e18;
for(int j=0;j<=mxt;j++)dp[0][j][0]=dp[0][j][1]=0;
for(int i=1;i<=n;i++){
dp[i][0][0] = 1e18;
dp[i][0][1] = 1e18;
for(int j=1;j<=mxt;j++){
dp[i][j][1] = min(dp[i-1][j][0] + a[i], (int)1e18);
if(j>=b[i]) dp[i][j][0] = max(dp[i-1][j-b[i]][1], j) + a[i];
else dp[i][j][0] = 1e18;
dp[i][j][1] = min(dp[i][j][1], dp[i][j][0]);
if(i==1 || i==n)dp[i][j][1] = dp[i][j][0];//not allowed to skip...
// cout<<i<<' '<<j<<' '<<dp[i][j][0]<<' '<<dp[i][j][1]<<'\n';
}
}
for(int j=1;j<=mxt;j++){
ans = min(ans, max(j, dp[n][j][0]));
ans = min(ans, max(j, dp[n][j][1]));
}
cout<<ans<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 16196kb
input:
6 3 1 1 1 1 2 1 5 3 3 7 4
output:
13
result:
ok single line: '13'
Test #2:
score: 0
Accepted
time: 0ms
memory: 8504kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
1 1 1
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 33ms
memory: 258280kb
input:
161 146 662 336 441 626 77 362 697 911 248 879 40 435 60 518 62 475 908 185 740 435 899 188 673 716 529 524 305 321 998 4 363 598 471 650 379 6 980 971 175 664 328 294 681 201 64 926 608 310 478 404 284 634 239 891 515 433 368 929 457 593 338 432 971 593 134 355 97 658 344 653 592 822 660 403 398 38...
output:
80587
result:
ok single line: '80587'
Test #5:
score: -100
Memory Limit Exceeded
input:
747 4 609 179 580 613 171 82 687 882 977 720 609 967 329 508 803 301 837 550 416 931 416 521 937 268 723 878 33 372 426 2 94 248 979 319 576 859 644 459 365 445 668 337 572 881 775 946 901 992 405 377 896 967 66 792 686 676 232 245 539 217 774 167 747 923 722 295 483 454 195 494 206 779 536 845 438 ...
output:
375240