Skip to content

Commit ec8181a

Browse files
committed
Added 1399B - Gifts Fixing.cpp
1 parent 24db001 commit ec8181a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

1399B - Gifts Fixing.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
7+
8+
int main()
9+
{
10+
int t;
11+
cin>>t;
12+
while(t--)
13+
{
14+
int n;
15+
cin>>n;
16+
long long c[n];
17+
long long o[n];
18+
long long minC = INT_MAX;
19+
long long minO = INT_MAX;
20+
for(long long i=0; i<n; i++)
21+
{
22+
cin>>c[i];
23+
minC = min(minC, c[i]);
24+
}
25+
for(int i=0; i<n; i++)
26+
{
27+
cin>>o[i];
28+
minO = min(minO, o[i]);
29+
}
30+
long long minMoves=0;
31+
for(int i=0;i<n;i++)
32+
{
33+
minMoves += max((c[i]-minC), (o[i]-minO));
34+
}
35+
cout<<minMoves<<endl;
36+
}
37+
}

0 commit comments

Comments
 (0)