QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55329#1172. Junkyeom's Contestfeecle6418AC ✓164ms5696kbC++20527b2022-10-13 11:18:152022-10-13 11:18:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 11:18:18]
  • 评测
  • 测评结果:AC
  • 用时:164ms
  • 内存:5696kb
  • [2022-10-13 11:18:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5;
int n,a[N+5],ans=-1;
bool cmp(int x,int y){
	return x>y;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=3;i+4<=n;i++){
		int s=a[i+1]+a[i+2]+a[i+3]+a[i+4];
		int p1=upper_bound(a+1,a+n+1,s-a[i],cmp)-a;
		for(int x=p1;x<i&&x<=p1+2;x++){
			int p2=upper_bound(a+1,a+n+1,a[x]+a[i],cmp)-a;
			if(p2>=x)continue;
			ans=max(ans,s+a[i]+a[x]+a[p2]);
		}
	}
	cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
1 2 3 4 5 6 7

output:

-1

result:

ok 1 number(s): "-1"

Test #2:

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

input:

8
1 2 3 4 5 6 7 8

output:

35

result:

ok 1 number(s): "35"

Test #3:

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

input:

10
5 5 5 5 5 5 10 5 5 5

output:

35

result:

ok 1 number(s): "35"

Test #4:

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

input:

7
141492387 72235422 49924898 183332532 178192988 192684636 147499872

output:

965362735

result:

ok 1 number(s): "965362735"

Test #5:

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

input:

8
24608515 140751563 43705451 113994713 52509537 32130709 117463343 87041819

output:

-1

result:

ok 1 number(s): "-1"

Test #6:

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

input:

9
2691939 114300407 182710197 139624191 31858791 176609486 152268030 30225807 79200011

output:

876571113

result:

ok 1 number(s): "876571113"

Test #7:

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

input:

10
2030518 198196518 40274071 183359971 71550121 96204862 199843967 46173607 196619138 2690754

output:

991948184

result:

ok 1 number(s): "991948184"

Test #8:

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

input:

11
85146646 26521171 179278816 8989449 50899375 135650934 129615950 94390299 27618702 179962232 2512657

output:

854944252

result:

ok 1 number(s): "854944252"

Test #9:

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

input:

12
63230070 95037311 78092074 34618927 179991732 80129711 4612126 132541583 48552857 167299118 76773097 141033928

output:

874125457

result:

ok 1 number(s): "874125457"

Test #10:

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

input:

20
52405440 186588704 109061481 152472140 16115810 148658854 66743034 28305150 77780684 119361360 8050516 1554301 154478790 146543678 187546138 32279893 41889899 80960260 117802881 188066499

output:

1164354803

result:

ok 1 number(s): "1164354803"

Test #11:

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

input:

21
135521569 160137548 7874739 123325809 195465063 93137631 46771913 171489138 3747543 1665542 82310956 163114045 92278880 171370111 59773357 109727810 30170326 140240523 86200899 82106547 153987440

output:

1155803868

result:

ok 1 number(s): "1155803868"

Test #12:

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

input:

22
8572289 133686393 146879484 148955287 174814317 132583704 71511192 114673126 24681699 189002429 61604100 19641085 189887482 50972352 176710976 187175727 58642240 134679569 159631621 26403492 101051189 178325936

output:

1255548488

result:

ok 1 number(s): "1255548488"

Test #13:

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

input:

23
91688417 162011045 45692742 174584765 103906675 22286673 51540072 57857114 45615854 71306611 190640347 35976636 127687572 170766082 48938195 169656348 141889962 193959831 128029640 120443541 48114937 198473713 159552755

output:

1260092131

result:

ok 1 number(s): "1260092131"

Test #14:

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

input:

50
134170081 56797965 35040736 45224325 5102476 106020832 167954026 119923972 151391400 39247099 72095141 146927386 116079799 14749285 135104039 39200818 179623552 24872203 57355273 63838168 42352783 174850365 194389351 35930945 10847154 80608047 3727586 122549184 104520573 35608953 66338849 7153646...

output:

1251688145

result:

ok 1 number(s): "1251688145"

Test #15:

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

input:

101
159147539 81989858 197503381 187945335 45245589 36372876 25243512 197516473 183157104 17275611 125659901 2325559 70116022 68253157 7587401 51206763 121627071 196400807 130951940 56514802 188575142 92512898 71305437 12187408 113124298 142632634 105677315 168121898 132428879 47722230 82875309 8100...

output:

1350461249

result:

ok 1 number(s): "1350461249"

Test #16:

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

input:

1000
57869894 12244197 102751325 191063232 21704902 118351183 111667041 14131481 156158495 132207266 11890152 1118704 74105790 120464458 163136546 186056258 1743030 36389366 141427747 104710546 10486332 10273816 162407523 90627683 144009771 58562152 115779647 9419967 188646785 82973793 155731062 287...

output:

1393894383

result:

ok 1 number(s): "1393894383"

Test #17:

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

input:

12345
138358873 75730912 161003206 117698439 135780183 199942555 166283522 34722641 103042592 165235220 10883424 34965397 130706431 164308262 5741877 140380744 87082738 103112834 147206601 145290355 159504940 162577962 141824730 153153205 65312404 57169655 12163862 144205759 197708613 6631189 122566...

output:

1399794489

result:

ok 1 number(s): "1399794489"

Test #18:

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

input:

123456
70379436 165625470 110791402 26345339 87853136 36815142 85418498 20677785 109678310 66720141 110422259 116030531 97600431 83933608 14345970 46783923 60047855 175823378 124835444 19676932 130471536 134850184 104759734 173714359 140683776 51589230 93486389 169013551 193952750 156996424 33525302...

output:

1399977050

result:

ok 1 number(s): "1399977050"

Test #19:

score: 0
Accepted
time: 77ms
memory: 4564kb

input:

234567
173603673 35133007 197048658 87158889 55628794 100958685 54724972 192287997 29648754 179537592 4360303 111664667 39298687 184083994 39640284 141334927 11544451 12768129 84930838 58740649 186713348 191631666 15026150 106283968 198106668 129396916 113083128 25391789 22605129 178721617 81031004 ...

output:

1399973986

result:

ok 1 number(s): "1399973986"

Test #20:

score: 0
Accepted
time: 103ms
memory: 5144kb

input:

345678
131603718 54383647 188338618 147972439 23404452 15359124 24031446 18674018 44586494 187322339 58106859 107298803 31253839 179201675 64934598 191175530 68073751 104488689 150058936 57612878 147987863 48413149 20259863 133820874 160562264 7204602 172871355 26994219 186416292 55222617 128536706 ...

output:

1399985638

result:

ok 1 number(s): "1399985638"

Test #21:

score: 0
Accepted
time: 155ms
memory: 5408kb

input:

456789
34827955 123891183 74595874 63561797 86147406 24726859 138562112 150092743 164556938 195107086 152044903 167774154 118176288 29095165 50037424 135983429 19570346 196209249 164930138 1709299 4229675 145386119 130526280 66390483 123017860 30236480 32659582 123563945 5003264 87013217 71009703 45...

output:

1399989327

result:

ok 1 number(s): "1399989327"

Test #22:

score: 0
Accepted
time: 134ms
memory: 5696kb

input:

499999
113304618 83631241 19375759 93433030 136825840 10671762 182282711 186985450 82030153 130390683 66120455 137150249 20987153 11570674 104586859 128367761 18640930 60537223 149164689 113846296 82901472 11641970 9919181 124797460 66921902 27672685 126261686 108462019 170854519 141037654 92170663 ...

output:

1399990098

result:

ok 1 number(s): "1399990098"

Test #23:

score: 0
Accepted
time: 164ms
memory: 5460kb

input:

500000
66684237 191361613 3815453 151033984 106928578 49148814 34397177 161775 94359148 54409762 3509627 76759320 100325182 92663506 187790026 149034824 29578676 154291084 147639250 190789935 169564488 52078051 47760578 70351713 43396094 140189069 152360589 199849175 176608985 40879843 148187497 179...

output:

1399977504

result:

ok 1 number(s): "1399977504"

Test #24:

score: 0
Accepted
time: 145ms
memory: 5420kb

input:

456789
20781152 47910826 183088351 129745580 189325410 31202627 160246873 7927247 155642598 83991025 149004808 183748686 122034940 89628819 71557087 84042680 164643736 177465991 25315316 161246303 56266769 198669365 138721536 23743963 136837798 116115332 167918818 79188871 123667188 43291235 1353904...

output:

1399982989

result:

ok 1 number(s): "1399982989"

Test #25:

score: 0
Accepted
time: 148ms
memory: 5656kb

input:

499999
198796123 21015363 111772842 6053491 154619567 59593490 21878860 108775938 166636159 185403464 192641343 143086591 42310539 23780494 31135935 105785373 162476328 115948100 105850331 133958149 14810562 193177340 7203319 134746580 101812052 25251837 11135306 120432283 106438641 156752065 123585...

output:

1399987776

result:

ok 1 number(s): "1399987776"

Test #26:

score: 0
Accepted
time: 156ms
memory: 5596kb

input:

500000
189642622 73971197 3345837 52042603 27221681 151154029 174892575 64288921 151780881 45288306 166319365 89017068 10946565 26777391 178806024 194171035 139477912 78735628 5967796 69950814 107343095 156199219 122640889 133095155 101483508 176436756 165359786 51835802 135027846 36065 44573953 110...

output:

1399983429

result:

ok 1 number(s): "1399983429"

Test #27:

score: 0
Accepted
time: 128ms
memory: 5536kb

input:

456789
155031425 23333167 159911100 56890909 182148979 104830445 94787015 37479211 178253577 130903572 131594639 123203725 190211019 63594326 27916440 156577919 9867991 90465562 35542074 38847537 147714911 113888506 138819872 129558601 54036265 32078661 52425674 110911838 49585933 120190846 88205067...

output:

1399992780

result:

ok 1 number(s): "1399992780"

Test #28:

score: 0
Accepted
time: 144ms
memory: 5596kb

input:

499999
38079099 141661896 143371399 133198820 42410432 133221309 156419002 138327902 134471329 32316011 175231174 82541630 110486617 153035602 42271096 43161828 157443688 174171863 116077089 11559383 106258703 13429185 7301654 40561218 178819031 101023678 45385265 6931058 127324682 128618972 1165914...

output:

1399986999

result:

ok 1 number(s): "1399986999"

Test #29:

score: 0
Accepted
time: 147ms
memory: 5664kb

input:

500000
123892895 194617730 85201290 179187932 115012545 129814551 54656909 93840885 79424563 92200853 94133388 18406699 184155348 50999795 30132673 76771682 39477975 191735198 121227258 147552048 93758532 176451064 27771929 38909793 18681975 147175892 199609746 138334577 50881183 26678780 92355824 1...

output:

1399986297

result:

ok 1 number(s): "1399986297"

Test #30:

score: 0
Accepted
time: 162ms
memory: 5624kb

input:

500000
952616 255858 515522 407944 835899 540638 725473 797747 199352 861768 388126 136097 129199 404364 975722 73250 491412 803212 247836 780681 900799 66605 980461 378988 101292 602264 762045 126631 919612 654842 25932 628314 79091 668036 620097 769511 2424 953003 828199 868405 954135 386665 39658...

output:

6999911

result:

ok 1 number(s): "6999911"

Test #31:

score: 0
Accepted
time: 113ms
memory: 5668kb

input:

500000
200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200000000 200...

output:

1400000000

result:

ok 1 number(s): "1400000000"

Test #32:

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

input:

12345
71375819 68239018 121117888 16332665 89835308 87001931 192121078 3855615 21086620 13387100 91796512 152645662 191201855 29842002 98780392 51440099 174186476 23890035 40224497 173441391 59467692 75572061 174883662 130738295 57043775 1870973 30962441 155165127 44405142 137829785 179995038 843990...

output:

1399644736

result:

ok 1 number(s): "1399644736"

Test #33:

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

input:

12345
49459243 41787863 114898442 41962142 164151857 126448004 172149958 52072308 96796584 95691282 166056951 9172702 129001946 4411539 15718011 128888016 107691094 178137594 113655219 67481439 6531440 150495647 89991172 152612679 184390336 126956990 144056662 40622692 17862559 30129655 147514264 15...

output:

1399465581

result:

ok 1 number(s): "1399465581"

Test #34:

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

input:

12345
27542667 15336707 53903187 117848516 143501111 16150972 101921941 90223592 22763443 83028169 145350095 170732446 66802036 29237972 87945230 56592829 190938817 37417856 187085941 11778384 153595189 170643424 5098681 119711254 111736897 197267198 97342371 166271745 146609575 122429526 115033490 ...

output:

1399475944

result:

ok 1 number(s): "1399475944"

Test #35:

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

input:

12345
110658795 83852847 57749149 143477994 177626172 160629749 31693924 138440284 43697599 165332351 19610534 82035293 109634830 3807509 4882849 134040746 124443435 136889606 155483959 156075329 5691641 190791202 174981998 141585637 134050754 172610110 10436593 41663902 65291183 14729396 27776908 1...

output:

1399155391

result:

ok 1 number(s): "1399155391"

Test #36:

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

input:

12345
183709515 162434396 196753895 169107471 156975426 75822 106690100 81624272 64631754 142603829 93870974 43595037 102210728 133666647 77110068 11488663 7691157 196169868 28914681 50115378 97979582 170747492 90089508 163460020 156364611 97696126 123530814 72345659 143781304 56772370 195296134 719...

output:

1399423222

result:

ok 1 number(s): "1399423222"

Test #37:

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

input:

8
61531745 190861462 95624082 90076858 79711831 37762792 85268480 43177396

output:

493153184

result:

ok 1 number(s): "493153184"

Test #38:

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

input:

8
191394975 47007157 181798379 35022421 122107599 71566385 68505746 59594034

output:

595198317

result:

ok 1 number(s): "595198317"

Test #39:

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

input:

8
120 60 60 31 31 31 31 31

output:

275

result:

ok 1 number(s): "275"

Test #40:

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

input:

7
120 60 60 31 31 31 31

output:

-1

result:

ok 1 number(s): "-1"

Test #41:

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

input:

9
126774506 68489897 183719064 75010496 24109192 58388918 191141564 87778967 180583892

output:

631693540

result:

ok 1 number(s): "631693540"

Test #42:

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

input:

10
67584743 85961231 196790246 96108096 68048756 86854290 68621816 41420547 89881010 824683

output:

563059942

result:

ok 1 number(s): "563059942"

Test #43:

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

input:

15
27251275 13186769 172674390 74800428 39809218 80215643 38695322 16021095 19057403 172805658 53447107 9875413 2967943 148179873 77787339

output:

647045266

result:

ok 1 number(s): "647045266"

Test #44:

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

input:

20
568190 49522807 80326529 4469075 83187925 48778540 43409594 250516 58899783 46273253 190393250 175563160 54836587 198782167 57533816 125739343 51261383 10143563 34417840 65529598

output:

719822978

result:

ok 1 number(s): "719822978"

Test #45:

score: 0
Accepted
time: 81ms
memory: 5660kb

input:

500000
1 1 1 1 1 1 4 4 4 7 10 13 19 25 34 49 67 91 127 175 241 334 460 634 877 1210 1669 2305 3181 4390 6061 8365 11545 15937 21997 30361 41908 57844 79840 110203 152110 209953 289795 399997 552106 762061 1051855 1451851 2003959 2766019 3817873 5269726 7273684 10039702 13857577 19127302 26400985 364...

output:

7

result:

ok 1 number(s): "7"

Test #46:

score: 0
Accepted
time: 80ms
memory: 5584kb

input:

500000
1 1 1 1 2 2 3 3 5 5 8 8 13 13 21 21 34 34 55 55 89 89 144 144 233 233 377 377 610 610 987 987 1597 1597 2584 2584 4181 4181 6765 6765 10946 10946 17711 17711 28657 28657 46368 46368 75025 75025 121393 121393 196418 196418 317811 317811 514229 514229 832040 832040 1346269 1346269 2178309 21783...

output:

9

result:

ok 1 number(s): "9"

Test #47:

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

input:

500000
1 1 1 1 2 3 4 5 7 10 13 18 24 33 44 60 81 109 147 199 268 362 488 659 889 1199 1618 2183 2945 3973 5360 7231 9755 13160 17753 23950 32309 43586 58799 79322 107008 144358 194744 262716 354413 478116 644995 870120 1173822 1583527 2136232 2881851 3887716 5244663 7075231 9544731 12876171 17370398...

output:

7

result:

ok 1 number(s): "7"

Test #48:

score: 0
Accepted
time: 71ms
memory: 5696kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

20

result:

ok 1 number(s): "20"

Test #49:

score: 0
Accepted
time: 118ms
memory: 5652kb

input:

500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

5499936

result:

ok 1 number(s): "5499936"

Test #50:

score: 0
Accepted
time: 68ms
memory: 5464kb

input:

500000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

31

result:

ok 1 number(s): "31"

Test #51:

score: 0
Accepted
time: 121ms
memory: 5584kb

input:

500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

output:

5499925

result:

ok 1 number(s): "5499925"