60,TLE,但是因为思路过于简单而不会优化。。。
查看原帖
60,TLE,但是因为思路过于简单而不会优化。。。
196020
lyxiang楼主2023/10/18 18:58

易!误!因为是小L先选的所以直接找最小值了。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100010;
const LL INF=-5000000000000000000;
int n,m,q;
LL A[N],B[N],res,ans;
int l1,r1,l2,r2;

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	for(int i=1;i<=m;i++) scanf("%lld",&B[i]);
	
	while(q--)
	{
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
	
		ans=INF;
		for(int i=l1;i<=r1;i++)
		{
			res=A[i]*B[l2];
			for(int j=l2;j<=r2;j++)
				{
					res=min(res,A[i]*B[j]); 
				}
			ans=max(ans,res); 
		}
		printf("%lld\n",ans);
	}
	
	return 0;
}
2023/10/18 18:58
加载中...