[BAILIAN] hihoCoder Challenge 34 register

Ended

Participants:186

Verdict:Accepted
Submitted:2018-07-15 18:41:09

Lang:G++

Edit
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
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
long long a[MAXN];
long long b[MAXN];
int t,n,m;
int cnt=0;
int main(){
    cin>>t;
    while(t--){
        long long ans=0;
        cin>>n>>m;
        for(int i=1; i<=n; i++){
            cin>>a[i];
        }
        for(int i=1; i<=m; i++){
            cin>>b[i];
        }
        sort(a+1,a+1+n);
        sort(b+1,b+1+m);
        if(a[n]<0&&b[1]>0){
            ans=a[n-1]*b[1];
        }
        else if(a[1]>0&&b[m]<0){
            ans=a[2]*b[m];
        }
        else if(a[1]*b[1]>a[n]*b[m]){
            ans=max(max(a[2]*b[m],a[2]*b[1]),max(a[n]*b[m],a[n]*b[1]));
        }
        else{
            ans=max(max(a[1]*b[1],a[1]*b[m]),max(a[n-1]*b[m],a[n-1]*b[1]));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX