QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#839170#9916. Defeat the EnemiesMaxduanWA 1ms5728kbC++231.9kb2025-01-01 14:00:432025-01-01 14:00:44

Judging History

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

  • [2025-01-01 14:00:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5728kb
  • [2025-01-01 14:00:43]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define pii pair<int,int>
#define maxn 30005
using namespace std;
int a[maxn],c[maxn];
const int p=998244353;
pii dp[maxn][101];
int A[maxn];

void solve(){
    int n,m;cin>>n>>m;
    for(int i=1;i<=2*m;i++){
        a[i]=0;
    }
    int mx=0;
    int maxy=0;
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    for(int i=1;i<=n;i++){
        int b;cin>>b;
        a[b]=max(a[b],A[i]);
        mx=max(mx,b+A[i]);
        maxy=max(maxy,b);
    }
    int k;cin>>k;
    dp[0][0].second=1;
    for(int i=1;i<=2*m+k;i++){
        for(int j=0;j<=k;j++){
            dp[i][j]={1e18,0};
        }
    }

    for(int i=1;i<=k;i++){
        cin>>c[i];
    }

    pii ans={1e18,0};

    for(int i=1;i<=2*m+k;i++){
        int tmp=0;
        for(int j=1;j<=k&&i-j>=0;j++){
            for(int u=0;u<=k;u++){
                if(dp[i-j][u].first==1e18)continue;
                int tp=max(u,tmp-mx);
                if(dp[i][tp].first==dp[i-j][u].first+c[j])(dp[i][tp].second+=dp[i-j][u].second)%=p;
                else if(dp[i][tp].first>dp[i-j][u].first+c[j]){
                    dp[i][tp]=dp[i-j][u];
                    (dp[i][tp].first+=c[j])%=p;
                }
            }
            if(a[i-j])tmp=max(tmp,j+i-j+a[i-j]);
        }
        for(int j=0;j<=k;j++){
            if(dp[i][j].first!=1e18&&i>maxy&&i>=j+mx){
                if(dp[i][j].first<ans.first)ans=dp[i][j];
                else if(dp[i][j].first==ans.first)(ans.second+=dp[i][j].second)%=p;
            }
        }
    }
    cout<<ans.first%p<<' '<<ans.second<<'\n';

}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    for(int i=1;i<=100;i++){
        dp[0][i].first=1e18;
    }
    int TT=1;cin>>TT;
    while(TT--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5688kb

input:

4
5 5
3 5 2 1 2
3 1 3 2 3
3
2 3 4
3 2
2 2 2
2 2 2
3
2 3 3
7 6
5 3 4 6 6 3 4
4 6 4 2 3 5 5
4
2 4 6 7
10 100
38 49 79 66 49 89 21 55 13 23
67 56 26 39 56 16 84 50 92 82
11
6 6 7 8 9 9 9 9 9 9 9

output:

9 1
6 4
18 18
99 44387

result:

ok 8 numbers

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 5728kb

input:

1000
5 3
1 1 3 1 2
3 2 1 1 2
1
5
5 3
3 3 2 2 1
1 1 3 1 1
3
3 1 3
5 5
4 3 5 1 4
5 5 2 5 5
2
1 5
5 5
5 5 5 5 4
2 1 2 4 1
2
1 1
5 3
2 1 2 1 1
1 3 2 1 1
1
5
2 1
1 1
1 1
3
2 2 1
5 5
2 3 5 2 2
5 2 4 3 1
2
3 3
5 1
1 1 1 1 1
1 1 1 1 1
3
5 4 4
5 4
1 4 4 4 2
4 3 1 3 3
1
2
1 5
2
2
3
4 2 4
1 5
4
5
1
4
2 5
1 5
1...

output:

20 1
3 1
9 1
5 4
20 1
3 2
15 4
9 3
14 1
4 1
36 1
12 1
27 1
2 1
20 1
4 1
10 1
23 1
10 1
6 2
28 1
4 1
5 1
4 1
6 1
8 1
6 1
16 1
9 6
5 1
30 1
4 1
4 1
2 1
35 1
10 1
2 1
4 1
15 6
4 1
20 1
4 1
6 1
40 1
4 1
18 1
8 1
7 1
6 1
2 1
10 1
3 1
9 1
8 1
4 1
6 3
20 1
8 2
10 1
2 1
2 1
50 1
24 1
6 1
10 16
10 1
6 1
3 1
...

result:

wrong answer 11th numbers differ - expected: '2', found: '3'