QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#475167#9129. Quotient Sumucup-team052#AC ✓53ms7748kbC++141.4kb2024-07-13 12:18:572024-10-14 07:33:41

Judging History

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

  • [2024-10-14 07:33:41]
  • 管理员手动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:53ms
  • 内存:7748kb
  • [2024-09-26 15:38:30]
  • hack成功,自动添加数据
  • (/hack/908)
  • [2024-07-13 12:18:57]
  • 评测
  • 测评结果:100
  • 用时:53ms
  • 内存:7844kb
  • [2024-07-13 12:18:57]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ "="),debug_helper::debug(__VA_ARGS__),D("\n")
#include"/home/xay5421/debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define each(x,v) for(auto&x:v)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
template<class T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<class T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
using namespace std;
using LL=long long;
using ULL=unsigned long long;
const int N=200005;
int n,L[N];
LL a[N],dp[N];
int main(){
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	rd(n);
	rep(i,1,n)rd(a[i]);
	sort(a+1,a+n+1);
	memset(dp,63,sizeof(dp));
	dp[1]=0;
	int pos=1;
	rep(i,2,n){
		while(a[i]/a[i-1]<a[i]/a[pos])++pos;
		L[i]=pos;
	}
	rep(i,2,n){
		dp[i]=min(dp[i],dp[i-1]+(a[i]/a[i-1]));
		dp[i]=min(dp[i],dp[L[i]]+(a[i]/a[L[i]]));
		if(L[i]>1){
			int j=L[i]-1;
			per(k,20,0)if(j-(1<<k)>=1){
				if(a[i]/a[j-(1<<k)]==a[i]/a[j])j-=1<<k;
			}
			dp[i]=min(dp[i],dp[j]+(a[i]/a[j]));
		}
	}
	printf("%lld\n",dp[n]);
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 3 6

output:

3

result:

ok "3"

Test #2:

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

input:

2
15 4

output:

3

result:

ok "3"

Test #3:

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

input:

9
284791808 107902 13660981249408 4622332661 13405199 24590921 361 244448137 16077087227955422

output:

4580

result:

ok "4580"

Test #4:

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

input:

9
12 9 5 17 2 6 7 1 15

output:

6

result:

ok "6"

Test #5:

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

input:

10
19 13 18 11 20 16 6 8 17 3

output:

4

result:

ok "4"

Test #6:

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

input:

8
5 7 11 16 2 15 1 20

output:

7

result:

ok "7"

Test #7:

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

input:

10
13 2 19 11 15 9 16 5 12 1

output:

7

result:

ok "7"

Test #8:

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

input:

8
9 1 14 11 3 12 8 20

output:

7

result:

ok "7"

Test #9:

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

input:

4
4 6 20 3

output:

5

result:

ok "5"

Test #10:

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

input:

382
1495 1297 1197 976 1335 486 1850 992 1483 1269 1898 1593 237 1342 711 957 1992 1401 1413 206 917 1831 1444 698 1291 1987 231 1559 1119 1822 1790 471 736 496 1157 1886 1974 699 1702 321 325 758 683 1826 1051 95 632 456 1224 1590 1394 1854 1226 1963 1926 1819 989 34 980 371 535 807 1541 144 433 12...

output:

11

result:

ok "11"

Test #11:

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

input:

317
1565 1374 387 1215 766 1670 862 673 1391 70 727 152 182 26 1111 1430 64 1318 349 994 780 1762 1993 552 715 1943 967 972 1039 646 617 1822 373 486 1863 1179 1840 1781 1963 220 773 671 126 613 719 1660 334 1851 65 707 1862 490 1466 1590 1717 1723 656 1526 1138 31 1976 1823 1335 1719 397 612 593 13...

output:

8

result:

ok "8"

Test #12:

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

input:

100
1070 947 7 1735 476 1172 995 2000 536 15 1499 656 1810 1435 639 1647 61 630 4 754 1594 442 1644 1743 5 629 1879 1707 1174 1984 1526 1829 1449 783 1483 1734 1032 494 537 1872 1117 1316 1069 780 520 689 31 1970 1653 1071 251 360 1063 988 1154 638 547 525 264 495 273 436 967 633 462 1863 164 402 18...

output:

12

result:

ok "12"

Test #13:

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

input:

495
368 27 1415 966 351 1575 449 1982 15 1207 1806 1483 1304 1488 750 1751 1047 314 1833 1365 1281 589 1062 419 1430 345 41 230 1248 11 338 1139 1146 1892 281 1994 950 26 1247 817 1250 131 1954 631 1020 1705 382 220 172 1434 1841 1866 849 793 1236 53 1275 1366 1038 1889 615 1652 218 1862 84 377 76 1...

output:

19

result:

ok "19"

Test #14:

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

input:

452
1711 258 865 1330 1923 4 1656 652 1660 1768 603 1841 646 1810 1235 200 503 1083 418 511 1803 886 54 213 1914 734 1531 1941 272 1686 1873 1831 1367 1746 141 404 1538 989 768 1830 1684 426 527 1872 1105 1655 540 1444 331 767 1896 49 1141 921 772 307 614 764 848 1997 1406 339 63 828 416 1891 1925 6...

output:

11

result:

ok "11"

Test #15:

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

input:

61
320 456 426 201 1105 1894 570 661 1307 618 956 1185 1241 6 574 1236 604 462 1900 1488 697 1688 1085 775 635 747 1252 1721 431 192 768 1798 1712 686 1496 932 1309 1431 904 1467 1863 804 856 1682 1159 78 1276 211 942 848 270 225 117 302 1418 1951 534 1345 591 110 1967

output:

19

result:

ok "19"

Test #16:

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

input:

6007
926195740081456592 954460021832145143 601395744686943902 21575530228356921 463431657670752021 711276919720293649 916086948281828983 942717046975828490 627872019769751663 375556646744053894 531095909932455304 993855300776486066 208335586285140634 319193845177757965 985795314563730251 10507706789...

output:

12

result:

ok "12"

Test #17:

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

input:

8261
284791808 107902 13660981249408 4622332661 13405199 24590921 361 244448137 16077087227955422 29020 2999 243823 11405 3084850839644 51410 1293 598217528 6419212814 19670 42431 16305842936592 588083868939790 35416223344083524 1670928183457 462015428 19431 7573789315 819 4594126473685 8554104 1422...

output:

63

result:

ok "63"

Test #18:

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

input:

6015
358871240359366151 224257618022883235 172819476860570817 75125953034362365 824984506523526062 988848382335902687 898522089822105149 755567463105677238 970409760639198928 430709898290812041 779827111538256956 857511190324448260 329465323773300663 685019732014997951 197724427289098867 15126091335...

output:

14

result:

ok "14"

Test #19:

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

input:

2319
7 769 14566 213732121851657504 3031249 117432 1853 43404611161 2137819942 2525662612281 575 628859144901512192 82402637244386 570993657677445760 244 540730562 190876 146904 11282 2881663495750947 36247 410727237 100465424998099 48557284 334485561776644672 1611191 191632019669065056 203 2122865 ...

output:

64

result:

ok "64"

Test #20:

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

input:

3647
191274254202747070 816451465136605666 632954453162088720 316484101993458936 400530481203520131 36361261508615425 107377728836074713 479766874026239333 132490733793819615 701342570200191348 393529093120808255 997930221798392349 37262148109322604 236346409115411 445572155956552286 578658600443172...

output:

15

result:

ok "15"

Test #21:

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

input:

2459
1418053410414 637622553455 1470 1931006024625 27526276968 4967139053 521674647989055 186443981371189 39480756299336 95680188183 2727948481 557901603 11423 10709859272749 242760849 307283093727562688 42213 3181 518822290138407936 1532145441957570 40684208181105 254735022780282 56 58 5905 166 193...

output:

63

result:

ok "63"

Test #22:

score: 0
Accepted
time: 29ms
memory: 6676kb

input:

113844
462209310844307827 895186606000026911 536883699910050004 923768182795407203 116843726498620270 837342622857072639 5401336272754811 956408591677017253 644988425043116019 643246228819184945 544277427880226394 694401128212891523 352892254813391858 739821579965916396 991683818573040504 7744776087...

output:

16

result:

ok "16"

Test #23:

score: 0
Accepted
time: 47ms
memory: 7612kb

input:

194435
2691485 412893522790905728 14698764318 223230348450 79466646146 106916997248562 668789825 15651263346034818 6602164367069652 7736843382176793 398591166927295 21282612274422 12609786010 463 73237470025259248 1756698204 17854370570384 364588 13045 1165416117509 22557532638431 28889662774652 649...

output:

62

result:

ok "62"

Test #24:

score: 0
Accepted
time: 7ms
memory: 6068kb

input:

28233
492525631319916156 711072765816623886 459232417094360150 178798507591150604 353974036315601613 194110040523143355 505141911910923391 664035751438995680 165712677460360109 173043053636817457 846663981201087731 374037523526255941 615493493779455262 402943770653209584 177780263822236862 587639656...

output:

19

result:

ok "19"

Test #25:

score: 0
Accepted
time: 25ms
memory: 6528kb

input:

95668
3858000880 60795117 38235057004215 298098951 64314296133179 18833904350356 120770850925 2774944191269 255141101 4154206501543 21211992074 2182387455404017 1081676 363628 100215812 2894 4715142770132 3907947523860996 14800803990578786 1539665 336976382981 346697971791917 14189195 1223709102 125...

output:

62

result:

ok "62"

Test #26:

score: 0
Accepted
time: 36ms
memory: 7496kb

input:

138737
344080383853530510 506164534912392073 139977616575079622 514052853498838453 152764635074458728 832083649720388173 993219396611857398 879660925480156303 453759956308175743 160600829699596235 323853232622454230 723843069506245926 575269759636569718 168343487411019088 838968602347042497 57119631...

output:

22

result:

ok "22"

Test #27:

score: 0
Accepted
time: 22ms
memory: 6508kb

input:

100166
1151157553 836591449264925312 313948 2676928393605 13001634471019 99365359359285008 769801072 697627803298476 191573 113952 845016 127215 11816661249 1354142147467898 457548 38436728826913 653 1401486 180932188831607 392180 225912447 52306519486088240 107369540422594 273624 1554040 370171615 ...

output:

62

result:

ok "62"

Test #28:

score: 0
Accepted
time: 52ms
memory: 7748kb

input:

200000
920958999654769887 44652757342146560 588489988140055764 699663983847393136 315612138966758196 363575024892322674 672781839441013508 88936379681887294 804875024546631171 658554778695822095 286444958264530140 23178858151405656 799137576073800100 663360499806895180 970593772223770261 59102126259...

output:

18

result:

ok "18"

Test #29:

score: 0
Accepted
time: 48ms
memory: 7748kb

input:

200000
174039034751809 3913449945 1231151041349148 1716357008 387750331009 265833 2128290757998 1581879 6554637 10528531 825870 54581638747659 61324040385337 73724654248641 2437818 2432559052495 1157877982 21743686292271 2608906738 17773353689 1340616779510480 212791991 6356509296744 27163067 371427...

output:

62

result:

ok "62"

Test #30:

score: 0
Accepted
time: 52ms
memory: 7748kb

input:

200000
608206876488013963 765742835263016526 404552338643357901 106165943051038032 661019497372534691 826671466097675376 154008041242843652 349350716523790060 114843035991741400 923861710816630325 502676115113668896 370704897782885594 937730204337141988 341874145536678500 893689026695611024 36360588...

output:

19

result:

ok "19"

Test #31:

score: 0
Accepted
time: 48ms
memory: 7688kb

input:

200000
147868401596385856 216988611781312 3142577822912 15277293516341 117746406342738 256984283219 564300524272028224 733656753 48331071205 455402217 6028756 12485 33225 271076 119063025316758624 9358818030569930 924666 492150932707103040 203341335439014 4385930676651 27248614129 14439049 186662971...

output:

62

result:

ok "62"

Test #32:

score: 0
Accepted
time: 47ms
memory: 7684kb

input:

200000
951721177876293159 170996162850303371 799238425724097973 477741534830539723 995930401206693919 657374179590985166 329086821700411311 609454572273843502 54543294048485422 819305692977092597 596293161077766507 894898386836465941 68509791070187014 364976989437807875 523648367694886346 7725358029...

output:

18

result:

ok "18"

Test #33:

score: 0
Accepted
time: 53ms
memory: 7648kb

input:

200000
935075 5200293 660465 12624 287192907 760535865 23881028 79277607409072560 90163533257784 345142177 3989 12145088 415115636533749248 1496354690718777 125569825487850 325525721 895741 35120072566556 30876357000311232 7442 57056874945 15011529 890928819587 11137912789 99883451555613712 26285956...

output:

62

result:

ok "62"

Test #34:

score: 0
Accepted
time: 35ms
memory: 7748kb

input:

200000
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:

20

result:

ok "20"

Test #35:

score: 0
Accepted
time: 4ms
memory: 7728kb

input:

200000
200000 200001 200002 200003 200004 200005 200006 200007 200008 200009 200010 200011 200012 200013 200014 200015 200016 200017 200018 200019 200020 200021 200022 200023 200024 200025 200026 200027 200028 200029 200030 200031 200032 200033 200034 200035 200036 200037 200038 200039 200040 200041...

output:

1

result:

ok "1"

Test #36:

score: 0
Accepted
time: 34ms
memory: 7676kb

input:

200000
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 2...

output:

10

result:

ok "10"

Test #37:

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

input:

200000
191759 191760 191761 191762 191763 191764 191765 191766 191767 191768 191769 191770 191771 191772 191773 191774 191775 191776 191777 191778 191779 191780 191781 191782 191783 191784 191785 191786 191787 191788 191789 191790 191791 191792 191793 191794 191795 191796 191797 191798 191799 191800...

output:

2

result:

ok "2"

Test #38:

score: 0
Accepted
time: 34ms
memory: 7664kb

input:

200000
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 2...

output:

11

result:

ok "11"

Test #39:

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

input:

200000
114853 114854 114855 114856 114857 114858 114859 114860 114861 114862 114863 114864 114865 114866 114867 114868 114869 114870 114871 114872 114873 114874 114875 114876 114877 114878 114879 114880 114881 114882 114883 114884 114885 114886 114887 114888 114889 114890 114891 114892 114893 114894...

output:

2

result:

ok "2"

Test #40:

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

input:

2
1 1000000000000000000

output:

1000000000000000000

result:

ok "1000000000000000000"

Test #41:

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

input:

200000
1 999999999999800002 999999999999800003 999999999999800004 999999999999800005 999999999999800006 999999999999800007 999999999999800008 999999999999800009 999999999999800010 999999999999800011 999999999999800012 999999999999800013 999999999999800014 999999999999800015 999999999999800016 999999...

output:

999999999999800003

result:

ok "999999999999800003"

Test #42:

score: 0
Accepted
time: 34ms
memory: 7676kb

input:

200000
3 4 16 17 18 19 20 21 22 23 24 25 26 27 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 2...

output:

119

result:

ok "119"

Test #43:

score: 0
Accepted
time: 34ms
memory: 7684kb

input:

200000
6 7 8 9 10 11 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 44...

output:

110

result:

ok "110"

Extra Test:

score: 0
Extra Test Passed