QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#491911 | #4207. Uplifting Excursion | kimmoqt# | 0 | 39ms | 21720kb | C++20 | 1.8kb | 2024-07-26 01:11:23 | 2024-07-26 01:11:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=105;
int dp[MX][MX*MX*2], dq[MX][MX*MX*2];
int N, L, A[MX], B[MX];
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin>>N>>L;
for(int i=N;i>=1;i--) cin>>A[i];
int zero;
cin>>zero;
for(int i=1;i<=N;i++) cin>>B[i];
for(int i=0;i<MX;i++) {
for(int j=0;j<MX*MX*2;j++) {
dp[i][j]=-1e9;
dq[i][j]=-1e9;
}
}
// negatives
dp[1][0]=0;
for(int i=1;i<=N;i++) {
for(int j=0;j<MX*MX*2;j++) {
for(int k=0;k<=A[i];k++) {
if(j+i*k<MX*MX*2)
dp[i+1][j+i*k]=max(dp[i+1][j+i*k],dp[i][j]+k);
}
}
}
// positives
dq[1][0]=0;
for(int i=1;i<=N;i++) {
for(int j=0;j<MX*MX*2;j++) {
for(int k=0;k<=B[i];k++) {
if(j+i*k<MX*MX*2)
dq[i+1][j+i*k]=max(dq[i+1][j+i*k],dq[i][j]+k);
}
}
}
if(L<-100*100 || L>100*100) {
cout<<"impossible"<<'\n';
return 0;
}
int ans=-1e9;
for(int i=0;i<MX*MX*2;i++) {
int j=L-i;
if(j>0) continue;
j=-j;
if(j>=MX*MX*2) continue;
ans=max(ans,dq[N+1][i]+dp[N+1][j]);
}
if(ans<0) {
cout<<"impossible"<<'\n';
return 0;
}
ans+=zero;
cout<<ans<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 21720kb
input:
1 5 0 0 6
output:
5
result:
ok single line: '5'
Test #2:
score: 5
Accepted
time: 3ms
memory: 21660kb
input:
50 2303 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 3 5 25 50 0
output:
47
result:
ok single line: '47'
Test #3:
score: 0
Wrong Answer
time: 39ms
memory: 21720kb
input:
50 -17964 18 21 8 47 11 30 0 34 11 22 10 29 14 39 25 42 16 47 6 39 0 4 28 5 4 39 43 47 14 49 24 37 22 47 23 31 18 28 43 14 44 26 46 40 27 17 41 7 13 25 27 20 17 13 23 30 9 16 5 25 46 22 35 44 34 39 19 19 33 11 30 30 41 20 1 9 39 34 31 26 28 13 13 21 45 11 32 30 35 37 22 31 1 9 43 18 31 41 34 39 2
output:
impossible
result:
wrong answer 1st lines differ - expected: '2060', found: 'impossible'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 4ms
memory: 21696kb
input:
30 38887954194235 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 444113827766 26 511237030935 22 696666627923 315938808146 20 952560827478 924020644151 850666790939 23 587888300072 23 797812801251 911390834853 677171102320 4 2 22 950650764450 278888113729 23 15 15 13 9 637120041802 20 1...
output:
impossible
result:
wrong answer 1st lines differ - expected: '5692035643249', found: 'impossible'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #6:
0%
Subtask #9:
score: 0
Skipped
Dependency #7:
0%
Subtask #10:
score: 0
Skipped
Dependency #1:
0%