QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491917#4207. Uplifting Excursionkimmoqt#0 0ms3580kbC++202.0kb2024-07-26 01:17:052024-07-26 01:17:06

Judging History

你现在查看的是最新测评结果

  • [2024-07-26 01:17:06]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3580kb
  • [2024-07-26 01:17:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MX=105;

int dp[MX][MX*MX*MX], dq[MX][MX*MX*MX];

ll N, L, A[MX], B[MX];

int main() {
        cin.tie(0); ios_base::sync_with_stdio(0);

        cin>>N>>L;

        if(L<-MX*MX*MX/2|| L>MX*MX*MX/2) {
                cout<<"impossible"<<'\n';
                return 0;
        }

        // negatives
        for(int i=N;i>=1;i--) cin>>A[i];

        ll zero;
        cin>>zero;

        // positives
        for(int i=1;i<=N;i++) cin>>B[i];

        for(int i=0;i<MX;i++) {
                for(int j=0;j<MX*MX*MX;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*MX;j++) {
                        for(int k=0;k<=A[i];k++) {
                                if(j+i*k<MX*MX*MX)
                                        dp[i+1][j+i*k]=max(dp[i+1][j+i*k],dp[i][j]+k);
                                else
                                        break;
                        }
                }
        }

        // positives
        dq[1][0]=0;
        for(int i=1;i<=N;i++) {
                for(int j=0;j<MX*MX*MX;j++) {
                        for(int k=0;k<=B[i];k++) {
                                if(j+i*k<MX*MX*MX)
                                        dq[i+1][j+i*k]=max(dq[i+1][j+i*k],dq[i][j]+k);
                                else
                                        break;
                        }
                }
        }

        int ans=-1e9;
        for(int i=0;i<MX*MX*MX;i++) {
                ll j=L-i;
                if(j>0) continue;
                j=-j;
                if(j>=MX*MX*MX) 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
Memory Limit Exceeded

Test #1:

score: 0
Memory Limit Exceeded

input:

1 5
0 0 6

output:

5

result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

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%