QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#331278#1362. Bad Packingaggrovector#WA 1ms40948kbC++14976b2024-02-18 04:23:152024-02-18 04:23:16

Judging History

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

  • [2024-02-18 04:23:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:40948kb
  • [2024-02-18 04:23:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
long long n,c,i,j,dp[1005][100005],a[1005],vi[100005];
bool flag;

int main() {
    cin >> n >> c;
    for (i=1;i<=n;i++) {
        cin >> a[i];
    }
    dp[0][0]=1;
    for (i=1;i<=n;i++) {
        for (j=0;j<=c;j++) {
            dp[i][j]=dp[i-1][j];
            if (j-a[i]>=0 && dp[i-1][j-a[i]]==1) {
                dp[i][j]=1;
                vi[j-a[i]]=1;
            }
        }
    }
    // for (i=0;i<=n;i++) {
    //     for (j=0;j<=c;j++) {
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    // for (i=1;i<=c;i++) {
    //     cout << vi[i] << ' ';
    // }
    // cout << endl;
    for (i=1;i<=c;i++) {
        flag=false;
        for (j=1;j<=n;j++) {
            if (dp[j][i]>0) {
                flag=true;
            }
        }
        if (vi[i]==0 && flag) {
            cout << i << endl;
            return 0;
        }
    }
}

詳細信息

Test #1:

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

input:

4 10
9
6
5
7

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 13916kb

input:

10 25
1
1
1
2
2
3
3
4
2
1

output:

20

result:

ok single line: '20'

Test #3:

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

input:

77 9383
203
6771
1608
6509
3213
3597
3416
3011
2241
740
5564
3113
360
3229
5819
5589
5210
4519
5270
6067
10
9147
4171
920
8325
263
8097
3400
9214
3927
8804
4805
8388
1211
523
3799
1124
8573
7491
5527
8026
8529
2510
6430
6171
1405
4820
7662
2449
7264
1419
6320
7272
3327
7042
1517
8326
881
2199
4664
9...

output:

9289

result:

wrong answer 1st lines differ - expected: '8240', found: '9289'