QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94921#4368. Oilnixnehc1AC ✓1505ms3856kbC++141.9kb2023-04-08 10:59:062023-04-08 10:59:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 10:59:07]
  • 评测
  • 测评结果:AC
  • 用时:1505ms
  • 内存:3856kb
  • [2023-04-08 10:59:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2010;
int n,val[2*N],tot,ans;
struct Point
{
    int x,y;
    friend inline Point operator + (const Point &a,const Point &b) {return (Point){a.x+b.x,a.y+b.y};}
    friend inline Point operator - (const Point &a,const Point &b) {return (Point){a.x-b.x,a.y-b.y};}
    friend inline int operator * (const Point &a,const Point &b) {return a.x*b.y-a.y*b.x;}
    friend inline bool operator == (const Point &a,const Point &b) {return (a.x==b.x)&(a.y==b.y);}
    friend inline Point operator * (const Point &a,const int &b) {return (Point){a.x*b,a.y*b};}
};
struct Line
{
    Point a,b;
};
struct node
{
    Point p;
    int val;
}b[2*N];
Line a[N];
Point base;

int sign(Point x)
{
    if(x.y<0) return 0;
    return 1;
}

bool cmp(node a,node b)
{
    if(sign(a.p)!=sign(b.p)) return sign(a.p)<sign(b.p);
    if((a.p*b.p)==0) return a.val>b.val;
    return (a.p*b.p)>0;
}

int work(Point x)
{
    base=x;
    tot=0;
    int sum=0,res=0;
    for(int i=1;i<=n;i++) 
    {
        if((a[i].a==x) || (a[i].b==x)) {sum+=a[i].b.x-a[i].a.x;continue;}
        if(a[i].a.y==x.y) continue;
        if(a[i].a.y<x.y) b[++tot]={a[i].a-base,(a[i].b.x-a[i].a.x)},b[++tot]={a[i].b-base,-(a[i].b.x-a[i].a.x)};
        else b[++tot]={(a[i].b-base)*(-1),(a[i].b.x-a[i].a.x)},b[++tot]={(a[i].a-base)*(-1),-(a[i].b.x-a[i].a.x)};
    }
    sort(b+1,b+tot+1,cmp);
    res=max(res,sum);
    for(int i=1;i<=tot;i++) 
    {
        sum+=b[i].val;
        res=max(res,sum);
    }
    return res;
}

signed main(void)
{
    scanf("%lld",&n);
    for(int i=1,x0,x1,y;i<=n;i++)
    {
        scanf("%lld%lld%lld",&x0,&x1,&y);
        if(x0>x1) swap(x0,x1);
        a[i]=(Line){(Point){x0,y},(Point){x1,y}};
    }
    for(int i=1;i<=n;i++) ans=max({ans,work(a[i].a),work(a[i].b)});
    
    printf("%lld\n",ans);
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3764kb

input:

5
100 180 20
30 60 30
70 110 40
10 40 50
0 80 70

output:

200

result:

ok single line: '200'

Test #2:

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

input:

3
50 60 10
-42 -42 20
25 0 10

output:

25

result:

ok single line: '25'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

1
-100 180 20

output:

280

result:

ok single line: '280'

Test #4:

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

input:

1
-1000000 1000000 1

output:

2000000

result:

ok single line: '2000000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3528kb

input:

1
-1000000 1000000 1000000

output:

2000000

result:

ok single line: '2000000'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3500kb

input:

1
-1000000 -999999 1000000

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3580kb

input:

1
1000000 999999 1000000

output:

1

result:

ok single line: '1'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

2
-1000 0 200
1 1000 200

output:

1000

result:

ok single line: '1000'

Test #9:

score: 0
Accepted
time: 379ms
memory: 3676kb

input:

1000
737368 429284 959063
-548693 513523 43074
243164 -465669 860567
422975 -244747 588631
-136535 -470055 501433
-580596 -269833 22422
476738 -448258 866889
358773 563858 950905
-923261 208187 66835
-295330 444422 360513
-903435 841952 491761
377801 520064 65247
479135 -307498 426574
-794533 -46924...

output:

490622362

result:

ok single line: '490622362'

Test #10:

score: 0
Accepted
time: 378ms
memory: 3664kb

input:

1000
393505 133958 96751
942939 72421 396439
-822694 -718897 366172
-833366 91559 389785
28456 -507666 398767
-178646 616985 288351
465302 236829 106233
-911686 531549 436738
946908 -619546 27459
840101 -51671 27117
904596 -552691 993402
-379495 -968868 996117
-993434 826061 624577
390359 750548 209...

output:

474626777

result:

ok single line: '474626777'

Test #11:

score: 0
Accepted
time: 383ms
memory: 3856kb

input:

1000
91153 -919136 629430
-928593 -340764 946503
-958781 151370 414466
776584 -865178 350581
266056 -678142 180528
855892 -61597 800115
-150759 821898 16625
286683 401612 387028
-104779 -495288 75284
-292434 725113 64163
925796 -886633 920311
-995416 275385 423913
-922152 395549 705834
138194 618689...

output:

482990936

result:

ok single line: '482990936'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

3
10 20 10
20 30 20
10 20 30

output:

30

result:

ok single line: '30'

Test #13:

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

input:

3
10 20 30
20 30 20
10 20 10

output:

30

result:

ok single line: '30'

Test #14:

score: 0
Accepted
time: 93ms
memory: 3820kb

input:

1000
-500 -499 3
-499 -498 4
-498 -497 3
-497 -496 4
-496 -495 3
-495 -494 4
-494 -493 3
-493 -492 4
-492 -491 3
-491 -490 4
-490 -489 3
-489 -488 4
-488 -487 3
-487 -486 4
-486 -485 3
-485 -484 4
-484 -483 3
-483 -482 4
-482 -481 3
-481 -480 4
-480 -479 3
-479 -478 4
-478 -477 3
-477 -476 4
-476 -4...

output:

4

result:

ok single line: '4'

Test #15:

score: 0
Accepted
time: 90ms
memory: 3660kb

input:

1000
-500 -499 3
-499 -498 4
-498 -497 3
-497 -496 4
-496 -495 3
-495 -494 4
-494 -493 3
-493 -492 4
-492 -491 3
-491 -490 4
-490 -489 3
-489 -488 4
-488 -487 3
-487 -486 4
-486 -485 3
-485 -484 4
-484 -483 3
-483 -482 4
-482 -481 3
-481 -480 4
-480 -479 3
-479 -478 4
-478 -477 3
-477 -476 4
-476 -4...

output:

4

result:

ok single line: '4'

Test #16:

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

input:

500
885456 935548 893024
644787 -652783 650298
808938 947594 815852
432081 -622268 435774
142740 -169702 143960
856557 925094 863878
261261 -736938 263494
930033 956540 937982
417456 924584 421024
594945 978958 600030
893646 933174 901284
547677 775565 552358
883935 916485 891490
821457 984796 82847...

output:

244491195

result:

ok single line: '244491195'

Test #17:

score: 0
Accepted
time: 79ms
memory: 3560kb

input:

500
45689 45688 429334
-25319 -25320 894329
522056 522055 312322
-235913 -235914 80549
-426659 -426658 805356
411907 411906 645880
426220 426221 921612
-231572 -231571 910658
-875534 -875533 98045
846207 846206 829899
537791 537790 316936
307422 307423 401580
944769 944770 344664
979191 979192 10757...

output:

3

result:

ok single line: '3'

Test #18:

score: 0
Accepted
time: 76ms
memory: 3576kb

input:

500
179265 179266 321892
-979392 -979391 937361
253303 253304 662093
15752 15753 454134
852294 852295 799415
-412075 -412074 216608
727687 727686 146860
-594461 -594460 201360
866097 866096 403699
558297 558298 877893
759626 759627 517730
-409242 -409243 646944
-117540 -117541 298990
-291402 -291401...

output:

3

result:

ok single line: '3'

Test #19:

score: 0
Accepted
time: 75ms
memory: 3628kb

input:

500
93517 93518 342725
-526642 -526641 673580
-677576 -677575 72016
945873 945874 659771
353454 353453 240805
-829016 -829015 865082
164010 164009 830895
560978 560979 311174
-692476 -692477 84711
536284 536283 727900
335375 335374 145312
417370 417369 61814
826406 826407 429567
-958557 -958556 9207...

output:

3

result:

ok single line: '3'

Test #20:

score: 0
Accepted
time: 3ms
memory: 3544kb

input:

1000
-314183 -313894 798067
-425756 -425118 798067
-292017 -290420 798067
-886889 -885538 798067
-467401 -466095 798067
-854994 -854815 798067
-513964 -513655 798067
-738214 -737165 798067
-370302 -370033 798067
-520695 -520311 798067
939776 940229 798067
-507203 -505083 798067
-430399 -430073 79806...

output:

10859

result:

ok single line: '10859'

Test #21:

score: 0
Accepted
time: 6ms
memory: 3608kb

input:

1000
382451 382452 78441
857836 857837 78441
901408 901409 78441
553681 553682 78441
958497 958498 78441
558159 558160 78441
-25805 -25804 78441
-347668 -347667 78441
-273817 -273816 78441
831018 831019 78441
-388683 -388682 78441
133277 133278 78441
687349 687350 78441
-840786 -840785 78441
-928903...

output:

1

result:

ok single line: '1'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3556kb

input:

40
-1000000 -999999 1
1000000 999999 1
-1000000 -999999 2
1000000 999999 2
-999997 -999996 3
999997 999996 3
-999991 -999990 4
999991 999990 4
-999979 -999978 5
999979 999978 5
-999955 -999954 6
999955 999954 6
-999907 -999906 7
999907 999906 7
-999811 -999810 8
999811 999810 8
-999619 -999618 9
999...

output:

2

result:

ok single line: '2'

Test #23:

score: 0
Accepted
time: 377ms
memory: 3656kb

input:

1000
-562471 -912107 906506
-274879 -684768 698460
-874397 -188848 93604
-28794 -705403 609340
-167399 672073 966800
574383 -905547 886644
-606533 550812 888727
1562 230412 549342
677277 -834070 132706
-449549 540411 221803
73145 952104 336019
829568 -100383 692127
829833 -903703 193961
-174794 -191...

output:

475321294

result:

ok single line: '475321294'

Test #24:

score: 0
Accepted
time: 378ms
memory: 3640kb

input:

1000
535429 -631156 23269
512514 443281 542836
819566 -570924 519963
590031 -433565 264096
923294 160073 940091
-593408 -22399 532315
684799 -775238 49209
147113 -229349 981796
-756171 -526454 792463
206727 -23932 752629
-966010 983032 506651
890735 874240 566955
116980 217648 481666
-256065 621601 ...

output:

520621781

result:

ok single line: '520621781'

Test #25:

score: 0
Accepted
time: 378ms
memory: 3616kb

input:

1000
-539833 289597 151993
-97690 368210 28207
-324216 -553930 596542
-186165 -607098 656556
-66638 955440 205040
395039 329828 131162
226670 -134576 92227
-955914 -406966 866136
92055 -780943 194200
911334 415803 292298
556810 -852515 101714
-343033 992805 225276
-63525 846157 772818
335979 638756 ...

output:

491071907

result:

ok single line: '491071907'

Test #26:

score: 0
Accepted
time: 350ms
memory: 3696kb

input:

1000
-575337 -573660 851311
686087 691270 873892
-638060 -639269 772876
-720300 -722235 245651
716357 725256 738087
488406 490701 246614
-727750 -731177 325662
-991421 -999235 200753
537028 533528 669169
122969 125027 367320
-760777 -756503 49216
246388 237769 474145
-531151 -521821 289201
489068 48...

output:

105038

result:

ok single line: '105038'

Test #27:

score: 0
Accepted
time: 357ms
memory: 3676kb

input:

1000
205431 197003 881149
-864713 -867761 485945
103404 107198 990073
74999 77596 650806
-255915 -253437 874190
744948 749615 48710
815593 825399 598966
191407 193371 814024
701448 692913 225997
-291367 -294844 760471
-28317 -23376 104332
190642 187676 514001
805351 797488 445584
-402481 -408400 532...

output:

109988

result:

ok single line: '109988'

Test #28:

score: 0
Accepted
time: 355ms
memory: 3692kb

input:

1000
-558787 -551785 414529
120708 117367 973219
52208 51253 365345
-817392 -819311 546764
364514 372039 29492
-455925 -458922 588004
723878 733467 500184
977966 972616 688853
-34109 -37970 906557
918076 913630 206217
432948 425377 848473
88518 85204 705668
-254455 -250148 690900
842171 838210 58930...

output:

95852

result:

ok single line: '95852'

Test #29:

score: 0
Accepted
time: 345ms
memory: 3820kb

input:

1000
-157084 -157031 185405
-452796 -452881 463752
591511 591484 977598
523880 523929 61733
476997 477001 518007
-172268 -172276 65342
727194 727244 48770
966693 966690 801748
-223375 -223328 848052
-510495 -510411 126903
461655 461593 227992
411293 411309 931068
-58673 -58621 284529
-90156 -90124 7...

output:

366

result:

ok single line: '366'

Test #30:

score: 0
Accepted
time: 340ms
memory: 3672kb

input:

1000
306232 306284 502945
433479 433417 876592
-210218 -210157 872427
-252484 -252474 757623
-407893 -407815 227373
932894 932800 44474
-871695 -871765 212158
187159 187201 638974
894022 894071 760736
411140 411171 305793
-336595 -336512 231004
383131 383196 518029
-528070 -528079 894547
120550 1206...

output:

322

result:

ok single line: '322'

Test #31:

score: 0
Accepted
time: 343ms
memory: 3572kb

input:

1000
-238925 -238996 224432
-752092 -752047 183057
286146 286090 253260
585403 585354 117949
-20067 -20048 257759
-323288 -323286 945046
-966696 -966599 767354
218085 218065 687818
-134562 -134477 320406
799157 799235 316087
492773 492780 625156
85051 85116 33060
1045 1061 788035
30271 30327 852769
...

output:

371

result:

ok single line: '371'

Test #32:

score: 0
Accepted
time: 341ms
memory: 3776kb

input:

1000
765193 765193 377744
-784373 -784373 391530
-330706 -330706 475509
349530 349530 887257
-583109 -583109 158120
699638 699638 268352
771899 771899 78706
753056 753056 546394
117356 117356 137367
931180 931180 957933
225981 225981 669848
-62771 -62771 32869
206592 206592 706224
637628 637628 5675...

output:

0

result:

ok single line: '0'

Test #33:

score: 0
Accepted
time: 1500ms
memory: 3848kb

input:

2000
-562311 -562310 985766
594472 594473 372479
-178003 -178002 762574
-253391 -253390 553791
-138948 -138947 90598
-97412 -97411 874559
659874 659875 292807
424559 424560 312347
105222 105223 716911
-902757 -902756 11807
411176 411177 673969
342551 342552 650414
-956681 -956680 76972
-194819 -1948...

output:

4

result:

ok single line: '4'

Test #34:

score: 0
Accepted
time: 1504ms
memory: 3648kb

input:

2000
-887753 -887752 404724
724046 724047 957791
-703081 -703080 340344
927562 927563 103216
992630 992631 352035
-587464 -587463 966759
-189871 -189870 717462
-155303 -155302 479334
209953 209954 344773
-881275 -881274 476467
-455010 -455009 154987
-61478 -61477 957555
-211119 -211118 15455
858290 ...

output:

8

result:

ok single line: '8'

Test #35:

score: 0
Accepted
time: 1499ms
memory: 3740kb

input:

2000
-13398 -13397 651308
438778 438779 106392
-980056 -980055 476576
-971701 -971700 861497
338379 338380 271416
-467547 -467546 287153
-644885 -644884 136944
-81843 -81842 753597
-530265 -530264 429395
-596683 -596682 9812
-287498 -287497 447937
-350707 -350706 253609
-822875 -822874 21630
-947072...

output:

16

result:

ok single line: '16'

Test #36:

score: 0
Accepted
time: 1505ms
memory: 3672kb

input:

2000
675859 675860 556169
-584853 -584852 667147
226791 226792 232710
-638320 -638319 444718
-725115 -725114 631591
65948 65949 610220
-2171 -2170 60676
-217210 -217209 497472
274559 274560 637695
-768466 -768465 144682
-717968 -717967 41946
-575055 -575054 426546
944403 944404 21382
346596 346597 9...

output:

28

result:

ok single line: '28'

Test #37:

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

input:

1000
-1000000 1000000 227965
-1000000 1000000 959376
-1000000 1000000 625867
1000000 -1000000 68512
1000000 -1000000 267242
-1000000 1000000 628405
-1000000 1000000 185557
-1000000 1000000 831681
-1000000 1000000 830877
-1000000 1000000 883925
-1000000 1000000 881126
-1000000 1000000 351724
-1000000...

output:

2000000000

result:

ok single line: '2000000000'

Test #38:

score: 0
Accepted
time: 391ms
memory: 3616kb

input:

1000
0 198476 519794
-500000 45298 128787
242746 500000 632799
140298 -1000000 371287
266496 1000000 693424
282570 -1000000 734455
-1000000 146834 387971
-500000 311488 808272
185898 1000000 487687
-500000 263760 686440
286294 -1000000 743961
351464 -1000000 910316
19268 -500000 62342
65666 0 180779...

output:

649382066

result:

ok single line: '649382066'