-
Notifications
You must be signed in to change notification settings - Fork 0
/
1342A.cpp
43 lines (43 loc) · 863 Bytes
/
1342A.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
// Jai shree ram
// Author - Ajaybansal
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(x) (x.begin().x.end())
// #define for(i, n) for (int i = 0; i < n; i++)
#define endl "\n"
#define ff first
#define ss second
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define int long long
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
signed solve()
{
fast();
int t;
cin >> t;
while(t--){
int x, y, a, b;
cin >> x >> y >> a >> b;
int ans1,ans2;
ans1=(abs(x-y)*a)+(min(x,y)*b);
ans2=(x+y)*a;
cout << min(ans1,ans2)<< '\n';
}
}
signed main()
{
solve();
return 0;
}