#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int n, m;
vector<ll> a, b;
vector<ld> r;
ll gcd(ll a, ll b){
if(b == 0) return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b){ return a / gcd(a, b) * b; }
int main(){
cin >> n >> m;
a.resize(n);
b.resize(n);
r.resize(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++) cin >> b[i];
ll tmp = 1;
for(int i = 0; i < n; i++) tmp = lcm(tmp, a[i]);
ll tot = n * m, c = 0;
for(int i = 0; i < n; i++){
r[i] = ld(tmp) / ld(a[i]);
c += r[i];
}
ld per = ld(tot) / ld(c), ans = 1e10;
ll count = 0;
for(int i = 0; i < n; i++){
r[i] *= per;
ans = min(ans, r[i] * a[i]);
count += r[i] * a[i];
}
cout << ((count < n) ? int(ans) : int(ans) + *min_element(a.begin(), a.end()) * (count / n));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |