QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#427157 | #8768. Arrested Development | ucup-team3282# | RE | 34ms | 42644kb | C++14 | 582b | 2024-06-01 10:24:53 | 2024-06-01 10:24:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int maxn=50;
const int maxv=100000;
const int INF=1e9;
int n;
int a[maxn],b[maxn];
int dp[2][maxn*maxv+10];
int ans=INF;
int main(){
ios::sync_with_stdio(0);
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i];
for(int i=1;i<=n;i++){
for(int j=0;j<=maxn*maxv;j++){
if(j>=a[i])
dp[i&1][j]=min(dp[(i&1)^1][j]+b[i],dp[(i&1)^1][j-a[i]]);
else
dp[i&1][j]=dp[(i&1)^1][j]+b[i];
}
}
for(int i=0;i<=maxn*maxv;i++){
ans=min(ans,max(i,dp[n&1][i]));
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 34ms
memory: 42640kb
input:
4 100 1 1 90 1 20 1 20
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 16ms
memory: 42644kb
input:
2 314 1 592 6
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 14ms
memory: 24776kb
input:
1 1 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 7ms
memory: 24432kb
input:
1 100000 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 9ms
memory: 23392kb
input:
1 1 100000
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 14ms
memory: 24092kb
input:
1 100000 100000
output:
100000
result:
ok single line: '100000'
Test #7:
score: -100
Runtime Error
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...