QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386854#8541. Activating Robotslifan100 ✓865ms206464kbC++142.1kb2024-04-11 20:43:202024-04-11 20:43:21

Judging History

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

  • [2024-04-11 20:43:21]
  • 评测
  • 测评结果:100
  • 用时:865ms
  • 内存:206464kb
  • [2024-04-11 20:43:20]
  • 提交

answer

// 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define dFor(i,a,b) for(int i=(a);i>=(b);i--)
#define tomin(x,y) x=min(x,y)
#define tomax(x,y) x=max(x,y)
#define ll long long
#define db double
#define pb push_back
#define gc getchar
const int N=1e5+5;
const ll I=1e18;
int read()
{
	int x=0,y=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') y=0;
	for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^48);
	return y?x:-x;
}
int L,R,n,K,m;
int a[N];
ll g[N][22];
ll f[1<<20|5][22];
map<int,int> mp;
int get1(int st,int ed)
{
	if(st<=ed) return ed-st;
	return L-st+ed;
}
int go(int u,int k) { return (u+k+L)%L; }
int lb(int x)
{
	if(x<=a[n]) return lower_bound(a+1,a+n+1,x)-a;
	return 1;
}
void pre()
{
	memset(g,63,sizeof(g));
	For(i,0,n)
	{
		For(j,1,R-1)
		{
			int nw=a[i],to=(nw+j*m)%L;
			int t2=(get1(to,nw)+K)/(K+1);
			int t3=go(to,t2);
			int t4=lb(t3);
//			cout<<get1(to,nw)<<" "<<t2<<" "<<t3<<" "<<t4<<endl;
			ll as1=t2+get1(t3,a[t4]);
			
			if(K>1)
			{
				int t2=(get1(nw,to)+K-2)/(K-1);
				int t3=go(to,t2);
				int t4=lb(t3);
				ll as2=t2+get1(t3,a[t4]);
				tomin(as1,as2);
//				cout<<"         "<<as1<<" "<<as2<<endl;
			}
			tomin(g[i][j],as1*K);
//			cout<<i<<" "<<j<<" "<<g[i][j]<<endl;
		}
	}
}
signed main()
{
//	freopen("P10285_17.in","r",stdin);
//	freopen("P10285.out","w",stdout);
	L=read(),R=read(),n=read(),K=read();
	m=L/R; int up=(1<<R)-1;
	For(i,1,n) a[i]=read();
	sort(a+1,a+n+1); n=unique(a+1,a+n+1)-a-1;
	For(i,1,n) mp[a[i]]=i;
	pre();
//	For(i,1,n)
//	{
//		For(j,1,R-1) printf("%lld ",g[i][j]); puts("");
//	}
	memset(f,63,sizeof(f));
	f[1][1]=0;
	for(int k=1;k<=up;k+=2) For(i,1,R) if((k>>i-1&1)&&f[k][i]<f[0][0])
	{
		ll t=f[k][i];
		int nw=mp[((i-1ll)*m+t/K)%L];
		For(j,1,R) if((k>>j-1&1^1))
		{
//			cout<<i<<" "<<j<<" "<<t<<" "<<g[nw][(j+R-i)%R]<<endl;
			tomin(f[k|1<<j-1][j],t+g[nw][(j+R-i)%R]);
		}
	}
	ll ans=I;
	For(i,1,R) tomin(ans,f[up][i]);
	printf("%lld\n",ans);
	return 0;
} 
/*
4
1 3
2 5
4 8
6 7

*/

詳細信息

Test #1:

score: 4.16667
Accepted
time: 8ms
memory: 201204kb

input:

10 2 1 2
6

output:

22

result:

ok single line: '22'

Test #2:

score: 4.16667
Accepted
time: 7ms
memory: 201208kb

input:

10 2 1 2
7

output:

4

result:

ok single line: '4'

Test #3:

score: 4.16667
Accepted
time: 4ms
memory: 201392kb

input:

32 4 5 2
0 23 12 5 11

output:

48

result:

ok single line: '48'

Test #4:

score: 4.16667
Accepted
time: 7ms
memory: 201384kb

input:

24 3 1 2
16

output:

48

result:

ok single line: '48'

Test #5:

score: 4.16667
Accepted
time: 31ms
memory: 206276kb

input:

325796798 2 100000 415814
130036882 134623756 319968467 118596706 81813191 184764752 211613431 240350767 122381690 95188488 110794026 64649345 150538562 62828748 185348390 281740201 259013226 63701012 42737041 185286671 7311148 289817702 33904049 301494116 296965958 128141108 38240586 66200241 88606...

output:

614157278

result:

ok single line: '614157278'

Test #6:

score: 4.16667
Accepted
time: 40ms
memory: 206336kb

input:

509200552 2 100000 63171
313719647 409874472 98563961 396585294 136198584 97378499 306046260 428432799 169231826 501174597 53233396 297344804 355364771 314448869 216773986 229212332 65256165 505523637 341800671 474608739 211756962 38249740 450310770 229086286 68069352 288563479 130143876 321269061 4...

output:

982688076

result:

ok single line: '982688076'

Test #7:

score: 4.16667
Accepted
time: 4ms
memory: 201332kb

input:

614228390 10 80 1
567707529 583474257 42643665 32067365 297742885 600180688 102630496 58901606 596578972 163193662 459913189 144237493 444023707 93662830 584967204 602405337 183142433 85802590 415591559 502344745 528668678 348723162 409918505 190594598 127136262 82777020 60863689 487612424 508549069...

output:

324039981

result:

ok single line: '324039981'

Test #8:

score: 4.16667
Accepted
time: 7ms
memory: 201396kb

input:

299651320 10 80 912224
168961578 236099322 69329024 270597716 232050321 209083311 249403346 83897162 279157717 82638991 251497304 160837274 148776110 144863657 152478307 199487929 160995819 4340196 276170418 253720439 214330401 258219738 47331192 285375315 259479565 3100628 145788088 262832544 86856...

output:

8573774442240

result:

ok single line: '8573774442240'

Test #9:

score: 4.16667
Accepted
time: 3ms
memory: 201228kb

input:

743972310 10 80 444351
53831864 632410420 522938004 681662893 323128224 297927355 78205776 716330383 675872450 426665635 491053574 148857585 322149372 99942542 307430259 577406843 548385688 463383589 272004828 6496438 545955891 730167532 223324091 459311029 446134253 293917701 608228397 359105211 45...

output:

2798243101221

result:

ok single line: '2798243101221'

Test #10:

score: 4.16667
Accepted
time: 0ms
memory: 201392kb

input:

665171430 10 80 353932
158645868 538045959 612775695 297958799 386960156 51539649 462476859 357296742 633121390 649090417 345677342 72407369 12619465 319757478 357208532 381958475 424956761 359733925 307111176 12628773 324426466 648079523 611883088 574352281 297742898 604807239 565969757 347260808 3...

output:

9064758440424

result:

ok single line: '9064758440424'

Test #11:

score: 4.16667
Accepted
time: 3ms
memory: 201288kb

input:

127169790 10 80 936506
39964410 108958041 102003225 125083605 79433720 104437991 85152728 62420724 107824913 50048406 31032784 26774351 96800739 101911600 83333053 98939850 27094072 98541586 31840548 74612018 41011465 112921206 68932687 107352311 106675620 112465412 51983874 2480174 59726940 8034814...

output:

6952747908816

result:

ok single line: '6952747908816'

Test #12:

score: 4.16667
Accepted
time: 11ms
memory: 201288kb

input:

114083960 10 80 215942
6829379 42408095 66085444 94087457 12335715 32322552 85150471 12044307 48247325 113884507 69509085 44779878 53685993 40140541 75025601 87088541 7542782 104042336 101114427 46206111 79812625 35168172 99521312 17413083 111526158 32755748 37395692 2347735 84524670 47404224 898702...

output:

790535373598

result:

ok single line: '790535373598'

Test #13:

score: 4.16667
Accepted
time: 129ms
memory: 206280kb

input:

604462320 16 100000 1
474034968 405571941 551954552 312068012 249243103 295665280 533416558 129347654 204569220 327641568 106755944 386106708 156615005 443411717 288517094 527561421 115510824 149485810 46800856 458057028 577820490 487049943 404716850 586267856 530207933 519574901 354385865 245507168...

output:

283427157

result:

ok single line: '283427157'

Test #14:

score: 4.16667
Accepted
time: 216ms
memory: 206356kb

input:

280520000 16 100000 2
13425246 215589280 246988696 119785555 42028716 11570723 231186671 120870879 91895072 215264953 5862286 40025638 104358996 207322003 196205111 139843402 138043819 112799988 268303073 54698130 247426866 110837436 176908185 47418782 18505573 173494299 195634023 261726826 27158047...

output:

175387934

result:

ok single line: '175387934'

Test #15:

score: 4.16667
Accepted
time: 218ms
memory: 206396kb

input:

974193232 16 100000 3
206718440 512298536 789669551 318756509 793659444 243899049 790668780 652812465 818256517 375195207 859456054 155502502 401063939 830985532 141523801 328461445 896736536 68345178 124027128 86602994 819336987 522620340 52144565 168437668 937462400 741778527 147121466 959308175 2...

output:

685310640

result:

ok single line: '685310640'

Test #16:

score: 4.16667
Accepted
time: 201ms
memory: 206340kb

input:

676090752 16 100000 262686
260571996 537618590 151294467 493673746 661994807 550419640 345856770 297595277 36997684 332130669 290081283 93897580 14315783 541526989 569709731 570243454 215277062 169441219 266811614 88354204 221912243 136854030 23126505 213590583 404773583 567546289 330123495 42577361...

output:

7240151532

result:

ok single line: '7240151532'

Test #17:

score: 4.16667
Accepted
time: 202ms
memory: 206340kb

input:

679246160 16 100000 234071
77013395 243800411 502858073 617521660 191569284 136748313 50880451 84758015 276491579 39481356 314319662 279720570 629294056 412300385 523667041 399793026 611800838 275735070 220472846 6307223 47759171 287285545 83062813 400669949 551886437 198162987 324173933 67680276 20...

output:

7802522714

result:

ok single line: '7802522714'

Test #18:

score: 4.16667
Accepted
time: 194ms
memory: 206288kb

input:

476883936 16 100000 108012
234762562 240408117 30415555 140472956 462154473 354136405 40572091 242004645 394275468 444433318 104170867 416956734 361648459 418263430 303170728 197867387 176638177 23328906 377338082 217613806 420907837 53916932 326342330 321967002 2753224 320762681 111651561 51698649 ...

output:

3096271992

result:

ok single line: '3096271992'

Test #19:

score: 4.16667
Accepted
time: 203ms
memory: 206356kb

input:

507510496 16 100000 663864
53866790 214804638 298521702 386235309 370595197 377166177 418011632 79251206 352193802 350178114 35723412 100373164 100247806 355435691 451755369 35253652 221268785 154520755 261068673 14395242 237015602 501200739 29905028 197395249 118231520 108675691 449082001 141374800...

output:

17834042496

result:

ok single line: '17834042496'

Test #20:

score: 4.16667
Accepted
time: 203ms
memory: 206360kb

input:

593679360 16 100000 306379
168642102 299060697 206475337 512602487 23373054 535063959 164981859 152255962 85828418 40158774 512366046 451752075 394221548 57919657 569807468 392816193 120984415 415048328 592692653 385727409 482807607 125053690 619913 491152927 516428234 338791756 15385741 485205200 5...

output:

6365023725

result:

ok single line: '6365023725'

Test #21:

score: 4.16667
Accepted
time: 725ms
memory: 206360kb

input:

894348360 20 100000 1
884469543 226814072 454421226 295854035 797272627 394622456 577723940 431157614 844694873 595642411 90258237 267778630 579656281 617936548 481683270 399592497 840545959 451636439 436534083 183406230 353608042 262260309 252674402 494972885 355632316 70618450 533859924 783505375 ...

output:

424977660

result:

ok single line: '424977660'

Test #22:

score: 4.16667
Accepted
time: 865ms
memory: 206364kb

input:

976034660 20 100000 2
492836120 298658168 746405489 191560699 523817619 839082997 522784842 585074485 235498803 351233093 118305896 755445786 207320083 99895488 462496799 748610155 551532558 739098419 868468295 526188148 867981270 384810831 401083017 347189112 55765243 487837848 410717201 335407832 ...

output:

618542150

result:

ok single line: '618542150'

Test #23:

score: 4.16667
Accepted
time: 780ms
memory: 206356kb

input:

224499000 20 100000 855523
135256786 158972486 76853429 63912701 155169119 48481519 39044232 84502269 69827413 110512939 116368481 135530271 152687298 110751283 38373440 87568147 151781461 154134822 95319993 38272745 21138098 185565335 192785907 218569011 48367852 155427671 32578671 224403063 154592...

output:

5734570669

result:

ok single line: '5734570669'

Test #24:

score: 4.16667
Accepted
time: 793ms
memory: 206464kb

input:

401140560 20 100000 289821
120424103 81690195 325479803 276059733 249260360 288229990 304123862 93368836 258121342 204253137 200849500 4853161 16581989 258621080 176878930 154911714 156899760 193976130 306836675 168000469 397033196 119818438 394731543 344822175 355562795 96575805 19002130 133325135 ...

output:

4836243027

result:

ok single line: '4836243027'