-
Notifications
You must be signed in to change notification settings - Fork 13
/
maximum profit.cpp
72 lines (47 loc) · 1.71 KB
/
maximum profit.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int t,m,n;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&m,&n);
int a[m][n];
int b[m][n];
long long int c[m][n];
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
scanf("%d",&b[i][j]);
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
cin>>c[i][j];
unsigned long long int sum=0;
for(int i=0;i<n;i++)
{
unsigned long long int now;
if(a[0][i]>=b[0][i])
now=b[0][i]*c[0][i];
else
now=a[0][i]*c[0][i];
sum=(sum>now)?sum:now;
}
unsigned long long int sum2=0;
for(int i=0;i<n;i++)
{
unsigned long long int now;
if(a[1][i]>=b[1][i])
now=b[1][i]*c[1][i];
else
now=a[1][i]*c[1][i];
sum2=(sum2>now)?sum2:now;
}
cout<<sum+sum2<<endl;
}
system ("pause");
return 0;
}