-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathB0058.cpp
46 lines (42 loc) · 779 Bytes
/
B0058.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
// Problem Code: MOVIEWKN
#include <iostream>
#include <vector>
#include <limits>
using namespace std;
int movieWeekend(vector<int> L, vector<int> R) {
int index, prod, maxR, maxProd;
maxR = maxProd = numeric_limits<int>::min();
for(int i=0 ; i<L.size() ; i++) {
prod = L[i]*R[i];
if(maxProd < prod) {
index = i + 1;
maxProd = L[i]*R[i];
maxR = R[i];
}
else if(prod == maxProd && maxR < R[i]) {
index = i + 1;
maxR = R[i];
}
}
return index;
}
int main() {
int T, n, num;
vector<int> L, R;
cin >> T;
while(T--) {
cin >> n;
for(int i=0 ; i<n ; i++) {
cin >> num;
L.push_back(num);
}
for(int i=0 ; i<n ; i++) {
cin >> num;
R.push_back(num);
}
cout << movieWeekend(L, R) << endl;
L.clear();
R.clear();
}
return 0;
}