QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662550#5146. SkillswlWA 236ms27648kbC++141.3kb2024-10-21 03:01:552024-10-21 03:01:55

Judging History

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

  • [2024-10-21 03:01:55]
  • 评测
  • 测评结果:WA
  • 用时:236ms
  • 内存:27648kb
  • [2024-10-21 03:01:55]
  • 提交

answer

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

const int N = 1005, L = 200, INF = 1e9;

int n;
int a[N][3];
int f[2][3][N+5][N+5];

void upd (int &x, int y) {
    if (y>x) x = y;
}

void solve () {
    cin >> n;
    for (int i=1; i<=n; i++)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    memset (f, -0x3f, sizeof(f));
    int ans=0;
    f[1][0][0][0] = f[1][1][0][0] = f[1][2][0][0] = 0;
    for (int i=1; i<=n+1; i++) {
        for (int id=0; id<3; id++) {
            for (int j=0; j<=i && j<=L; j++) {
                for (int k=0; k<=i && k<=L; k++) { 
                    if (j != i-1)
                        f[i&1][id][j][k] -= j;
                    if (k != i-1)
                        f[i&1][id][j][k] -= k;
                    if (i == n+1) {
                        upd (ans, f[i&1][id][j][k]);
                        continue;
                    }
                    upd (f[i+1&1][id][j+1][k+1], f[i&1][id][j][k]+a[i][id]);
                    upd (f[i+1&1][(id+1)%3][k+1][1], f[i&1][id][j][k]+a[i][(id+1)%3]);
                    upd (f[i+1&1][(id+2)%3][1][j+1], f[i&1][id][j][k]+a[i][(id+2)%3]);
                    f[i&1][id][j][k] = -INF;
                }
            }
        }
    }
    cout << ans << '\n';
}

int main () {
    ios::sync_with_stdio(false);
    int t; cin >> t; while (t --) solve ();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 27600kb

input:

2
3
1 1 10
1 10 1
10 1 1
5
1 2 3
6 5 4
7 8 9
12 11 10
13 14 15

output:

26
41

result:

ok 2 number(s): "26 41"

Test #2:

score: 0
Accepted
time: 15ms
memory: 27596kb

input:

1
200
6219 3608 2383
1139 2158 8611
6721 8216 8887
8736 6707 9755
7210 248 167
3849 276 8050
971 5062 1914
8290 1562 6017
8993 7990 3460
6323 6099 757
7652 4740 6117
6560 4206 180
3705 8906 5752
9619 8939 9696
793 6680 1777
384 3606 8772
9258 3906 709
4396 5083 6614
6057 4410 3132
8596 825 7437
6098...

output:

1505431

result:

ok 1 number(s): "1505431"

Test #3:

score: 0
Accepted
time: 23ms
memory: 27596kb

input:

1
200
7577 2771 7429
8435 7489 1440
1929 8819 818
7849 8462 8761
3344 5938 3673
9434 8897 6486
4668 636 8139
4777 3305 4238
4221 3326 639
3879 7469 1590
6370 9514 4307
6243 3301 8122
4967 184 9327
6142 1710 399
6814 9296 6270
5663 3564 5442
8315 1295 869
2635 7975 4837
9613 9439 4012
6660 1861 368
8...

output:

1497632

result:

ok 1 number(s): "1497632"

Test #4:

score: 0
Accepted
time: 46ms
memory: 27588kb

input:

1
300
0 10000 0
0 10000 0
0 10000 0
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
10000 0 0
0 0 10000
1000...

output:

2975228

result:

ok 1 number(s): "2975228"

Test #5:

score: 0
Accepted
time: 95ms
memory: 27648kb

input:

1
500
10000 0 0
10000 0 0
10000 0 0
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10000 0
0 0 10000
0 10...

output:

4955301

result:

ok 1 number(s): "4955301"

Test #6:

score: 0
Accepted
time: 14ms
memory: 27524kb

input:

20
10
6219 3608 2383
1139 2158 8611
6721 8216 8887
8736 6707 9755
7210 248 167
3849 276 8050
971 5062 1914
8290 1562 6017
8993 7990 3460
0 0 0
10
7652 4740 6117
6560 4206 180
3705 8906 5752
9619 8939 9696
793 6680 1777
384 3606 8772
9258 3906 709
4396 5083 6614
6057 4410 3132
1 0 0
10
6098 4958 7691...

output:

71054
70167
68631
74395
65914
65051
62880
65098
62727
71034
64500
71945
54364
66298
74354
70243
65959
78873
58698
72175

result:

ok 20 numbers

Test #7:

score: 0
Accepted
time: 30ms
memory: 27528kb

input:

10
100
6477 7917 2869
3623 818 611
7204 100 8682
4362 969 2510
6908 984 5181
2260 1731 6628
4216 5142 96
2604 5754 1992
2495 6672 7175
2278 7381 2075
1083 8778 9329
7535 4274 7337
8259 7742 6826
2873 2891 7320
2082 1988 6680
3674 1820 6637
2634 2964 5548
9745 2848 1275
2120 8514 4029
4256 692 7567
1...

output:

754578
728471
732747
758719
749241
761073
730494
756306
758915
732583

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 198ms
memory: 27648kb

input:

2
500
8487 2637 3423
692 627 5666
87 6242 9920
1603 3997 7168
3038 8194 4174
4170 4094 4270
8111 680 3974
7191 3780 9484
8222 3973 9422
3202 2613 6381
3555 8378 4605
9207 3035 9493
4615 6623 2865
370 5620 2590
1426 1407 2360
6168 1634 6195
7107 2847 9756
9348 2785 1270
1202 8847 7473
9872 4547 4904
...

output:

3783170
3641473

result:

ok 2 number(s): "3783170 3641473"

Test #9:

score: 0
Accepted
time: 235ms
memory: 27592kb

input:

1
1000
2436 2493 6048
2415 2847 3401
4000 8444 8174
286 1596 9946
4482 92 4023
3285 9065 5969
1319 7918 5651
5422 9158 4362
2990 8014 5657
2640 3851 6258
3504 5431 9522
7128 4980 9585
8784 1719 6032
4035 9446 1840
2646 7045 9738
1432 6172 5430
7667 1619 5145
2065 3899 1069
105 1751 8728
3615 8641 12...

output:

7542174

result:

ok 1 number(s): "7542174"

Test #10:

score: 0
Accepted
time: 86ms
memory: 27524kb

input:

100
10
1 6 9
3 7 5
10 9 3
6 1 10
6 9 5
7 9 7
6 9 3
9 4 9
8 8 5
9 2 8
10
7 4 9
4 1 3
7 1 5
1 10 4
6 9 1
8 10 2
1 1 10
2 10 6
6 6 4
5 7 4
10
9 4 2
4 2 8
4 2 4
10 5 4
10 7 6
6 9 8
5 2 10
6 8 8
7 1 2
6 9 6
10
1 3 2
5 10 3
3 4 4
10 2 2
9 9 6
9 8 1
3 2 8
5 2 8
6 3 4
8 10 4
10
2 10 10
5 4 1
6 9 1
10 9 3
10...

output:

75
67
70
62
68
72
61
58
66
59
65
61
77
65
63
84
71
72
79
74
67
57
81
72
51
63
66
71
80
73
73
72
79
68
71
61
62
71
60
64
67
60
73
69
60
58
62
72
62
69
65
59
59
70
61
70
55
66
83
76
79
74
58
62
75
67
68
61
56
68
70
69
52
71
66
69
72
65
66
69
67
71
70
73
62
83
77
68
68
72
64
66
71
68
66
67
64
68
70
57

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 39ms
memory: 27528kb

input:

10
100
5 9 10
10 2 3
4 2 1
10 10 4
6 8 7
6 9 4
5 5 1
5 7 1
10 7 10
3 6 3
10 4 9
2 3 1
7 9 1
5 4 2
4 3 8
9 2 8
5 10 10
6 1 3
4 8 4
2 8 1
2 2 5
6 7 6
7 4 3
2 10 5
7 4 6
7 5 3
6 1 5
3 2 4
9 3 5
10 9 8
2 7 5
4 9 8
10 10 1
2 10 5
5 8 4
7 4 7
7 2 1
3 6 8
2 7 3
1 7 5
5 10 4
9 5 5
8 10 7
3 2 9
8 1 2
6 9 2
1...

output:

585
625
580
595
574
577
628
591
584
553

result:

ok 10 numbers

Test #12:

score: -100
Wrong Answer
time: 236ms
memory: 27592kb

input:

1
1000
7 3 8
9 3 5
10 7 5
10 5 5
2 10 5
10 6 1
8 4 8
3 5 8
8 10 1
6 5 8
7 9 4
7 9 9
4 1 5
4 9 7
9 3 6
4 7 10
6 3 7
3 4 7
7 6 7
1 9 10
9 9 5
5 1 9
10 8 1
4 2 9
8 6 1
8 9 9
6 7 9
8 2 3
9 5 5
6 3 3
4 4 6
2 6 5
5 4 10
7 5 6
6 2 2
9 1 5
4 3 5
9 7 4
5 3 7
4 1 4
1 6 9
5 10 4
7 4 9
1 3 6
6 5 1
4 1 10
5 7 8
...

output:

4369

result:

wrong answer 1st numbers differ - expected: '5684', found: '4369'