QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132714#4928. Game With NumbersThyl0 11ms4968kbC++141.2kb2023-07-31 04:31:252023-07-31 04:31:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-31 04:31:28]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:4968kb
  • [2023-07-31 04:31:25]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
vector<int> a,b;
int INF=0;
int minimax(int step,vector<int> elements){
	if(step==m){
		int sum=0;
		for(int i=0;i<elements.size();i++)sum+=elements[i];
		return sum;
	}if(step%2==0){
		//premier joueur min
		int mini=INF;
		//erase div
		vector<int> ED;
		for(int &v:elements){
			if(v%b[step]){
				ED.push_back(v);
			}
		}
		//erase !div
		vector<int> END;
		for(int &v:elements){
			if(v%b[step]==0){
				END.push_back(v);
			}
		}
		mini=min(mini,minimax(step+1,ED));
		mini=min(mini,minimax(step+1,END));
		return mini;
	}else{
		//second joueur max
		int maxi=-INF;
		//erase div
		vector<int> ED;
		for(int &v:elements){
			if(v%b[step]){
				ED.push_back(v);
			}
		}
		//erase !div
		vector<int> END;
		for(int &v:elements){
			if(v%b[step]==0){
				END.push_back(v);
			}
		}
		maxi=max(maxi,minimax(step+1,ED));
		maxi=max(maxi,minimax(step+1,END));
		return maxi;
	}
}
signed main(){
	cin>>n>>m;
	a.resize(n);
	b.resize(m);
	for(int i=0;i<n;i++){
		cin>>a[i];
		INF+=a[i];
	}
	INF+=42;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	cout<<minimax(0,a)<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

5 1
-5000111000 -5000222000 -15 5 2
5

output:

-10000333010

result:

ok single line: '-10000333010'

Test #2:

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

input:

1 1
4
4

output:

0

result:

ok single line: '0'

Test #3:

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

input:

1 1
-400000000000000
400000000000000

output:

-400000000000000

result:

ok single line: '-400000000000000'

Test #4:

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

input:

7 1
8 -1 -2 -9 5 3 -5
3

output:

-6

result:

ok single line: '-6'

Test #5:

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

input:

20000 1
-400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -400000000000000 -40...

output:

-8000000000000000000

result:

ok single line: '-8000000000000000000'

Test #6:

score: 0
Accepted
time: 9ms
memory: 3944kb

input:

20000 1
400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 4000...

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 9ms
memory: 3872kb

input:

20000 1
-71369186400903 -21303325779163 -97827461296555 -214132697955012 -196334833414389 -301936452329789 -382174513230544 -367394070689093 -219406802243067 -9558534773577 -330359703722617 24771323320621 15923681295764 -301614836381862 28586018531489 -74683043436219 -124135635944320 -10648832568409...

output:

-3607837516244021000

result:

ok single line: '-3607837516244021000'

Test #8:

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

input:

20000 1
233033381367060 60861233878571 347212183474786 -84818202084737 -233828045019529 -393504707324582 353159561005753 -110028076672707 -114833693071773 199219445924758 166468140403099 54437974337128 302678275176822 -172792066320760 -39393106960029 -282021409620224 186724411035278 31109977318229 -...

output:

-51353784701877908

result:

ok single line: '-51353784701877908'

Test #9:

score: -3
Wrong Answer
time: 9ms
memory: 3964kb

input:

20000 1
259276559450483 289816807429370 -346039222749615 27387823542230 375860934333993 -389352017613855 -311669269024107 321679266510763 -218467767104130 233355728228893 254623964396522 -367362969133313 266826918011316 -353725186724477 165128555208345 -200053627141839 79271694277875 253842426527683...

output:

-18012762240899868

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #15:

score: 6
Accepted
time: 9ms
memory: 4008kb

input:

20000 2
400000000000000 400000000000000 400000000000000 399999999999999 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 400000000000000 399999999999999 400000000000000 399999999999999 400000000000000 400000000000000 399999999999999 400000000000000 399999999999999 4000...

output:

3948000000000000000

result:

ok single line: '3948000000000000000'

Test #16:

score: 0
Accepted
time: 9ms
memory: 4052kb

input:

20000 2
182534839165186 70298512307304 389011527035061 17719186879755 173234501403065 299252387908755 156279428310107 -53468549407874 231983453347369 185595967982888 169571810287905 -112087920827993 365797541703357 -25349506737522 41239046248334 -148328819397811 80677342299710 50496185442999 3661562...

output:

408111326270709915

result:

ok single line: '408111326270709915'

Test #17:

score: 0
Accepted
time: 9ms
memory: 4200kb

input:

20000 2
218341929058610 113825266508950 121595505352950 -266649636489390 372691257506875 179007493239720 397838524296340 -277455533023185 -94840528158885 217347955859550 28622416443405 87805939966390 354614659862895 195207146310200 -268725390905755 -46296909528395 121209367951465 -367727040846525 33...

output:

0

result:

ok single line: '0'

Test #18:

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

input:

20000 2
395005725351249 208925533233056 370067432849697 -32292841344081 119705875252473 390006267156590 182021792361812 373942452150496 131651909751951 194868764687583 -310709963285496 185234270501602 -201237683305028 347662803738748 -395444715472187 -161459593569143 -364088659843392 207669567395887...

output:

184269549641235344

result:

ok single line: '184269549641235344'

Test #19:

score: 0
Accepted
time: 8ms
memory: 4224kb

input:

20000 2
116652975053630 60104321156340 -96584001368190 -266671454064060 307611122473040 228559133687280 -174863279198680 280205821685540 279981438604220 -158968079945690 142528833962150 101495202175140 370765018135660 372285686790750 175771120431660 -85711229337990 -342487498445017 156470713488120 -...

output:

89404597022232604

result:

ok single line: '89404597022232604'

Test #20:

score: 0
Accepted
time: 9ms
memory: 4036kb

input:

20000 2
231340216652324 256966723495253 55755970208939 18995037562238 40202115515306 205614422465647 198180465653526 352558308489362 130632690026657 136195592925145 376946112957128 363137818059883 35528831434382 216513118579719 270648824719091 190806044676988 279809284882951 28688494358407 184799626...

output:

2003248538023267678

result:

ok single line: '2003248538023267678'

Test #21:

score: 0
Accepted
time: 10ms
memory: 4328kb

input:

20000 3
384932075704620 -220975224710020 -394461881400459 28957402981307 204299530009879 71623823434060 -299465787509940 -220007273108480 -369774774356700 225587136214180 -103750665533375 -218791548517520 28155270728460 -340828350186510 -364760095356115 136719577403944 364648512931666 25141508616892...

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 10ms
memory: 4872kb

input:

20000 4
-6583097811612 -58132996113366 130226342358498 -302471354703242 218561225027708 -308216597111396 -158340791587048 -216481924427320 100851414823772 212081645535710 -317294934422216 348848551231538 -324839761355052 -244449111635152 258020432603870 236173097232520 84794272197096 67047545335560 ...

output:

0

result:

ok single line: '0'

Test #23:

score: -6
Wrong Answer
time: 11ms
memory: 4968kb

input:

20000 8
298078912603948 78438259347402 140749094444945 -329303347640239 -129306754152072 -61765825553144 -339118683925351 11785340629263 -73607611340821 -33658379101816 140352907902536 -354864194969228 177325478536234 394946827562194 384388252688480 -70456837528868 -21018275840807 -151534523121821 -...

output:

-39641363131015319

result:

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

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Memory Limit Exceeded

Test #151:

score: 0
Memory Limit Exceeded

input:

20000 200000
251159317 887191501 857733752 384683418 134050448 506121340 780905769 276370704 109535211 872899439 556774439 434676879 148563667 12737512 153656019 878376794 609869178 575053645 396025679 379898138 703697683 487484329 551835906 619319386 488957017 16140328 920609560 848562444 895060489...

output:


result:


Subtask #8:

score: 0
Memory Limit Exceeded

Test #155:

score: 0
Memory Limit Exceeded

input:

20000 200000
396977329688022 -8423371363214 383571122639006 99712372108087 291078785047968 388310484655305 362117849739665 -120348551555749 26985765506461 192508503736541 185676740370600 -214164742554207 352594619152236 382485504805765 -152156638968634 -12362549868218 381290775270609 -39341784805470...

output:


result:


Subtask #9:

score: 0
Skipped

Dependency #1:

0%