//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
//#define N 100005
void solve(){
int N, M; cin >> N >> M;
vector<int> A(N), B(N);
for(auto &x:A) cin >> x;
for(auto &x:B) cin >> x;
for(int i = 0; i < N; ++i) A[i] = max(A[i], B[i]);
int l = 0, r = 1e18 + 5;
while(r != l){
int s = 0, mid = (l + r) / 2;
for(int i = 0, t = 0; i < N; ++i){
t = mid;
if(t >= M * A[i]) t -= A[i] * M, s += M;
else {
s += t / A[i];
if(t % A[i]) s++;
continue;
}
s += t / B[i];
if(t % B[i]) s++;
}
if(s <= N * M) l = mid;
else r = mid - 1;
}
cout << l << '\n';
}
signed main(){
starburst
int t = 1; //cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1046 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1046 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1046 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |