QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407611#795. Cloud Computingsichengzhou#54 264ms5392kbC++142.1kb2024-05-09 06:55:232024-05-09 06:55:24

Judging History

This is the latest submission verdict.

  • [2024-05-09 06:55:24]
  • Judged
  • Verdict: 54
  • Time: 264ms
  • Memory: 5392kb
  • [2024-05-09 06:55:23]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2020,M=52;
bool fl=1;
#define x first
#define y second
typedef long long LL;
typedef pair<bool,LL> pbL;
int n,m;
struct Node{
    int c,f,v,type;
    bool operator <(const Node &t)const
    {
        return f<t.f;
    }
}a[N+N],p1[N],p2[N];
int tot,s,s1;
pbL f[N*M],g[N+N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        tot++;
        scanf("%d%d%d",&a[tot].c,&a[tot].f,&a[tot].v);
        a[tot].type=1;
        if(a[tot].v>1)fl=0;
        s+=a[tot].c;
        p1[i]=a[tot];
    }
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        tot++;
        scanf("%d%d%d",&a[tot].c,&a[tot].f,&a[tot].v);
        a[tot].type=2;
        if(a[tot].v>1)fl=0;
        s1+=a[tot].c;
        p2[i]=a[tot];
    }
    sort(a+1,a+tot+1);
    sort(p1+1,p1+tot+1);
    sort(p2+1,p2+tot+1);
    f[0].x=1;g[n].x=1;
    if(fl==0)
    {
    for(int i=1;i<=tot;i++)
    {
        pbL cur;
        if(a[i].type==1)
        {
            for(int j=0;j<=s1;j++)
            {
                cur=f[j];
                cur.y-=a[i].v;
                f[max(j-a[i].c,0)]=max(f[max(j-a[i].c,0)],cur);
            }
        }else{
            for(int j=s1-a[i].c;j>=0;j--)
            {
                cur=f[j];
                cur.y+=a[i].v;
                f[j+a[i].c]=max(f[j+a[i].c],cur);
            }
        }
    }
    printf("%lld\n",f[0].y);
    }else{
    for(int i=tot;i>=1;i--)
    {
        pbL cur;
        if(a[i].type==1)
        {
            for(int j=1;j<=n+m;j++)
            {
                cur=f[j];
                cur.y+=a[i].c;
                f[j-1]=max(f[j-1],cur);
            }
        }else{
            for(int j=n+m-1;j>=0;j--)
            {
                cur=f[j];
                cur.y-=a[i].c;
                if(cur.y>=0)
                {
                    f[j+1]=max(f[j+1],cur);
                }
            }
        }
    }
    for(int i=n+m;i<=n;i--)
    {
        if(f[i].x==1)
        {
            printf("%d\n",i);
            break;
        }
    }
    }
    return 0;
}

详细

Subtask #1:

score: 18
Accepted

Test #1:

score: 18
Accepted
time: 0ms
memory: 3716kb

input:

1
3 3253 744
1
1 2012 798

output:

54

result:

ok single line: '54'

Test #2:

score: 18
Accepted
time: 0ms
memory: 3864kb

input:

1
1 2291 728
1
3 3024 858

output:

0

result:

ok single line: '0'

Test #3:

score: 18
Accepted
time: 1ms
memory: 3872kb

input:

8
18 5754 6872
11 5543 1464
6 6940 9405
10 5152 4196
13 5784 7499
18 6787 260
14 5922 218
17 5037 7983
100
3 5482 4812
1 3922 7167
3 3566 8041
2 3532 3839
3 3948 4490
2 5301 6616
3 4216 796
2 4583 5021
1 3311 3984
3 3044 2702
2 4529 288
2 3352 6474
2 3102 4548
3 3784 2968
2 5054 2143
2 5385 1542
3 3...

output:

368159

result:

ok single line: '368159'

Test #4:

score: 18
Accepted
time: 1ms
memory: 3856kb

input:

7
11 6380 2002853
5 6813 1069986
13 5521 2570534
12 5793 1980585
9 6767 423810
19 5421 2358687
3 6223 527470
200
2 5408 222070
2 5072 205933
1 5263 95185
2 4419 43779
2 4337 128477
1 4234 73697
2 3655 35020
1 3599 60877
1 3391 14190
1 4499 59363
3 5218 428777
1 3617 15308
1 3932 67554
1 3847 16460
2...

output:

909469

result:

ok single line: '909469'

Test #5:

score: 18
Accepted
time: 130ms
memory: 4724kb

input:

15
38 253050473 94982
19 873235634 3331
34 96232154 99722
18 361560017 18236
1 43839514 70819
30 211957237 36759
21 276441039 97496
10 677009897 39625
43 899961447 35095
15 278681496 20167
16 777735821 93692
39 295651318 33500
40 814700985 79446
14 174272701 32273
33 149679268 37695
1900
23 83103560...

output:

7591941

result:

ok single line: '7591941'

Test #6:

score: 18
Accepted
time: 44ms
memory: 4196kb

input:

15
2 26589073 403672469
1 41525134 919365487
1 20631561 281192925
1 102777840 841011960
1 39965286 293659571
1 25731340 899094489
2 13795262 388700479
2 28949306 887569930
2 28301652 432739525
3 21401611 995905557
1 12908533 333560050
1 72630405 571268998
1 34438002 497580454
1 69595535 544742664
1 ...

output:

8077488943

result:

ok single line: '8077488943'

Test #7:

score: 18
Accepted
time: 264ms
memory: 5384kb

input:

15
48 695425366 943332504
45 712641768 231446475
47 634507753 371099212
48 428534339 104593262
46 729756277 470795290
50 928986319 548613644
50 788811011 128576493
48 345438587 877886664
47 925824152 799912937
47 313626363 126112358
46 451672372 689015214
50 838817670 270199427
48 150219527 52297669...

output:

7473136555

result:

ok single line: '7473136555'

Test #8:

score: 18
Accepted
time: 263ms
memory: 5392kb

input:

15
41 18252721 748361561
41 23829617 977014296
46 13332057 613274621
42 21746541 913354722
47 12012296 564577912
42 16440276 690491591
46 12022310 553026259
50 15767600 788380000
41 19620669 804447428
46 17824167 819911682
50 14624259 731212950
41 14693399 602429359
46 20592200 947241200
49 14448618...

output:

4484130835

result:

ok single line: '4484130835'

Subtask #2:

score: 18
Accepted

Dependency #1:

100%
Accepted

Test #9:

score: 18
Accepted
time: 0ms
memory: 3916kb

input:

1
3 3299 1200
2
2 2283 1024
2 2149 1770

output:

570

result:

ok single line: '570'

Test #10:

score: 18
Accepted
time: 1ms
memory: 3916kb

input:

5
1 1 5
1 7 17
1 5 13
1 9 21
1 4 11
5
1 15 33
1 8 19
1 14 31
1 11 25
1 6 15

output:

0

result:

ok single line: '0'

Test #11:

score: 18
Accepted
time: 0ms
memory: 3772kb

input:

100
5 3988 363
4 3239 709
2 4302 878
1 4138 455
1 3928 337
3 4006 417
2 4785 946
4 4737 648
2 3833 723
5 4562 477
1 3226 456
5 3568 277
1 3069 602
5 3364 874
4 3724 370
5 4720 939
3 3135 449
5 4700 552
4 3607 314
2 4779 217
1 4655 611
2 4878 551
5 3228 356
3 4458 625
1 4768 634
2 4896 798
2 3822 845...

output:

0

result:

ok single line: '0'

Test #12:

score: 18
Accepted
time: 1ms
memory: 3928kb

input:

100
2 4437 307926
2 4247 167130
1 4684 186733
2 4073 238659
1 3804 48731
3 3056 45708
2 3860 112024
2 4647 371585
3 3259 197199
1 4768 42372
1 3036 12459
3 3710 229671
4 4841 440511
1 3988 68687
4 3549 687968
2 3738 359574
2 3607 68959
4 3430 440612
4 3748 407532
4 4325 578735
2 4401 348560
1 3105 3...

output:

64383

result:

ok single line: '64383'

Test #13:

score: 18
Accepted
time: 2ms
memory: 3892kb

input:

900
16 78097 37837
15 85865 62139
49 31064 68151
16 58456 44102
37 32228 30053
21 49446 89428
14 57170 73364
27 35608 58145
21 68753 11458
17 59071 88943
49 42236 95365
16 63378 50821
38 14523 14873
35 30920 21578
25 77237 43260
30 40988 91773
45 94488 74532
30 59827 80439
48 99962 82003
10 13024 57...

output:

88600698

result:

ok single line: '88600698'

Test #14:

score: 18
Accepted
time: 1ms
memory: 3808kb

input:

900
1 12538 73489
1 14027 83274
1 13786 81682
2 13114 83609
1 26371 84117
1 27061 86572
1 28859 93003
1 13256 78192
1 18003 54981
1 11495 33356
1 26985 86301
1 15525 46619
1 11442 66369
1 18010 55004
1 12575 73730
1 20680 64162
1 29344 94746
1 12976 76354
1 11220 64937
2 10053 62181
1 11445 99583
1 ...

output:

37709616

result:

ok single line: '37709616'

Test #15:

score: 18
Accepted
time: 3ms
memory: 3984kb

input:

2000
6 84742360 86208510
37 841445753 240119795
36 925517345 663647148
38 176682386 280265895
36 524950464 57753727
32 72381535 638240474
40 204984951 269332513
44 320717849 87706581
5 998168978 168525713
18 165301380 884951148
15 161182430 143651904
31 480907165 44152030
39 897236092 437065186
39 7...

output:

6758697884

result:

ok single line: '6758697884'

Test #16:

score: 18
Accepted
time: 0ms
memory: 3988kb

input:

2000
2 27652228 347036385
13 28320347 832939387
1 430926982 981306874
5 46590950 517148665
1 24099332 48704155
1 22582582 136548610
3 88481938 592470679
1 106641630 458410140
1 162431552 710496731
1 42671896 264908112
1 84014730 178799288
1 191515606 421722564
3 11001494 67575122
8 21004881 36802898...

output:

134698680

result:

ok single line: '134698680'

Test #17:

score: 18
Accepted
time: 0ms
memory: 3964kb

input:

1937
41 1 4
44 1 20
46 1 7
46 1 7
47 1 12
44 1 18
41 1 3
48 1 2
48 1 19
43 1 11
48 1 6
40 1 4
40 1 1
48 1 19
45 1 2
49 1 3
47 1 19
48 1 11
50 1 17
46 1 13
49 1 3
48 1 15
46 1 18
48 1 11
48 1 12
40 1 3
41 1 6
40 1 11
44 1 2
47 1 12
41 1 2
47 1 12
40 1 6
45 1 6
41 1 16
41 1 6
48 1 5
41 1 15
50 1 19
47...

output:

9016347060

result:

ok single line: '9016347060'

Subtask #3:

score: 18
Accepted

Test #18:

score: 18
Accepted
time: 0ms
memory: 3760kb

input:

12
1 3728 3883
1 2483 1377
1 2421 2213
1 4866 648
1 2292 1737
1 4027 657
1 2119 2801
1 2559 859
1 3859 3261
1 2908 3110
1 2917 2467
1 2011 3406
18
1 2558 4956
1 3468 2947
1 4577 4082
1 2886 2222
1 2979 3572
1 2266 4860
1 2868 3183
1 3665 4259
1 2607 4802
1 2811 3874
1 2314 4212
1 2638 3152
1 2944 44...

output:

23934

result:

ok single line: '23934'

Test #19:

score: 18
Accepted
time: 0ms
memory: 3920kb

input:

12
1 2208 8567
1 2221 8626
1 2152 8312
1 2293 8956
1 2261 8809
1 2062 7905
1 2203 8544
1 2105 8099
1 2280 8896
1 2057 7882
1 2015 7693
1 2162 8357
18
1 2563 10209
1 2000 7626
1 3072 12633
1 2789 11276
1 2144 8276
1 2921 11906
1 2380 9357
1 2077 7972
1 2103 8090
1 2868 11652
1 2684 10778
1 3043 12493...

output:

0

result:

ok single line: '0'

Test #20:

score: 18
Accepted
time: 1ms
memory: 3720kb

input:

79
1 4427 4256458
1 3723 3490767
1 3982 3260428
1 3770 3355873
1 4741 4551396
1 5000 1319580
1 4063 2173424
1 2181 4525445
1 3737 1728963
1 3931 4866468
1 4157 4762822
1 4236 1841301
1 2378 2709820
1 4220 2261004
1 2446 4168561
1 4547 2573600
1 3060 2878656
1 4672 4605556
1 2852 3719524
1 4693 42886...

output:

20786601

result:

ok single line: '20786601'

Test #21:

score: 18
Accepted
time: 0ms
memory: 3772kb

input:

79
1 2056 12536
1 2597 8192
1 4936 68413
1 2084 25464
1 2720 34555
1 3791 50555
1 4363 59390
1 4401 14996
1 2332 28967
1 3914 52440
1 4042 13602
1 4057 27320
1 2954 9495
1 4090 13787
1 4478 61188
1 4040 27189
1 3415 22425
1 4636 47751
1 2837 36264
1 4816 33255
1 3383 44370
1 2916 28067
1 3901 52240
...

output:

237760

result:

ok single line: '237760'

Test #22:

score: 18
Accepted
time: 1ms
memory: 3944kb

input:

224
1 6270 93747369
1 6502 167724928
1 6437 264148706
1 4077 760036221
1 5697 879487623
1 4557 733795468
1 6903 407495462
1 4106 697615090
1 7426 694689028
1 6401 689447791
1 7806 714964788
1 6997 288721199
1 5680 267711948
1 6188 217596834
1 7122 588728375
1 5561 436746734
1 5953 13086744
1 5223 33...

output:

40094608225

result:

ok single line: '40094608225'

Test #23:

score: 18
Accepted
time: 1ms
memory: 3880kb

input:

224
1 5309 28215
1 6848 18732
1 4262 55227
1 4660 48801
1 7916 66044
1 4018 31030
1 5015 26480
1 6577 17908
1 4879 51363
1 7792 86523
1 4023 31073
1 5349 56904
1 4124 10647
1 5126 67834
1 6453 52599
1 7970 44364
1 7728 85732
1 6969 76407
1 6245 33809
1 6330 85806
1 5045 13328
1 6873 18808
1 7161 984...

output:

1397706

result:

ok single line: '1397706'

Test #24:

score: 18
Accepted
time: 1ms
memory: 3852kb

input:

250
1 414892080 475780331
1 389986020 498894352
1 466122353 629641334
1 105791542 964215227
1 108319175 465600284
1 672601741 82971811
1 249420710 401256555
1 149341259 342168603
1 567366454 947578513
1 435092128 806081813
1 780065289 367591037
1 715227604 87185140
1 959201300 62189501
1 257570515 5...

output:

58593606691

result:

ok single line: '58593606691'

Test #25:

score: 18
Accepted
time: 0ms
memory: 3836kb

input:

250
1 139452088 615617196
1 108712470 470545881
1 218593295 999953196
1 200154778 909239851
1 216513655 989690503
1 206416295 939973840
1 101136346 870514051
1 210214974 958655407
1 107570262 465212767
1 114343906 496903861
1 169066882 757820712
1 130284386 572057468
1 178646230 804261003
1 20928398...

output:

11992746282

result:

ok single line: '11992746282'

Subtask #4:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 1ms
memory: 3724kb

input:

10
2 1 2274
2 1 2524
1 1 2699
5 1 2930
4 1 1802
2 1 2734
4 1 1036
3 1 2741
5 1 1138
1 1 2132
6
5 1 3573
1 1 4847
2 1 3885
1 1 2183
2 1 2534
1 1 4659

output:

0

result:

wrong answer 1st lines differ - expected: '17705', found: '0'

Subtask #5:

score: 0
Wrong Answer

Test #34:

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

input:

4
43 2536 1
48 2001 1
49 3407 1
48 3778 1
2
42 3314 1
43 3073 1

output:


result:

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

Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%