QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780649#9750. 拼图Zpair#WA 18ms3956kbC++20933b2024-11-25 12:05:512024-11-25 12:05:57

Judging History

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

  • [2024-11-25 12:05:57]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3956kb
  • [2024-11-25 12:05:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int calc(int A,int B,int C,int D){
	if(A<4)return 0;
	int mx=4;
	for(int i=0;i<=1000;++i){
		int cB=B-(i+1)*2,cC=C-(i+1)*2;
		if(cB<0||cC<0)continue;
		int k=min({cB/2,cC/2,(D-(i+i+1))/(2*i+1)/2});
		if(k>=0)mx=max(mx,(k*2+3)*(2*i+3));
	}
	for(int i=0;i<=1000;++i){
		int cB=B-i*2,cC=C-(i+1)*2;
		if(cB<0||cC<0)continue;
		int k=min({cB/2,cC/2,D/(2*i+1)/2});
		if(k>=0)mx=max(mx,(k*2+2)*(2*i+3));
	}
	for(int i=1;i<=1000;++i){
		int cB=B-i*2,cC=C-i*2;
		if(cB<0||cC<0)continue;
		int k=min({cB,cC,D/(2*i)});
		if(k>=0)mx=max(mx,(k+2)*(i*2+2));
	}
	return mx;
}
void solve(){
	int A,B,C,D;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(A<4){
		puts("0");
		return;
	}
	printf("%d\n",max(calc(A,B,C,D),calc(A,C,B,D)));
	/*
		ABCBA
		CDDDC
		BDDDB
		CDDDC
		ABCBA
	*/
}
int main(){
	int T;cin>>T;
	while(T--)solve();
}
//4A kB kC (k-1)D
//4A kB kC (2k-4)D

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3956kb

input:

2
4 0 0 0
4 4 4 4

output:

4
16

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 18ms
memory: 3896kb

input:

10000
0 0 0 0
0 0 0 1
0 0 0 2
0 0 0 3
0 0 0 4
0 0 0 5
0 0 0 6
0 0 0 7
0 0 0 8
0 0 0 9
0 0 1 0
0 0 1 1
0 0 1 2
0 0 1 3
0 0 1 4
0 0 1 5
0 0 1 6
0 0 1 7
0 0 1 8
0 0 1 9
0 0 2 0
0 0 2 1
0 0 2 2
0 0 2 3
0 0 2 4
0 0 2 5
0 0 2 6
0 0 2 7
0 0 2 8
0 0 2 9
0 0 3 0
0 0 3 1
0 0 3 2
0 0 3 3
0 0 3 4
0 0 3 5
0 0 3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 4021st lines differ - expected: '4', found: '6'