# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
538079 |
2022-03-16T05:01:50 Z |
ddy888 |
Self Study (JOI22_ho_t2) |
C++17 |
|
335 ms |
5108 KB |
#undef _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int unsigned long long
#define ll unsigned long long
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {cerr<<" "<<to_string(H);debug_out(T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
int N, M;
int A[300010], B[300010];
int good(int x) {
int cnt = 0;
for (int i = 1; i <= N; ++i) {
int a = 0, b = 0;
if (x <= A[i] * M) {
a = (ll)(x + A[i] - 1) / (ll)A[i];
} else {
a = M;
b = (ll)(x - (M * A[i]) + B[i] - 1) / (ll)B[i];
}
cnt += a + b;
if (a * (ll)A[i] + b * (ll)B[i] < x) return 0;
}
return cnt <= (ll)M * N;
}
int32_t main() {
fast;
cin >> N >> M;
for (int i = 1; i <= N; ++i) cin >> A[i];
for (int i = 1; i <= N; ++i) {
cin >> B[i];
A[i] = max(A[i], B[i]);
}
int lo = 0, hi = (1ll << 61);
while (lo + 1 < hi) {
int mid = (lo + hi) / 2;
if (good(mid)) lo = mid;
else hi = mid;
}
cout << lo;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
178 ms |
5108 KB |
Output is correct |
12 |
Correct |
184 ms |
5036 KB |
Output is correct |
13 |
Correct |
187 ms |
4940 KB |
Output is correct |
14 |
Correct |
211 ms |
5004 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Incorrect |
335 ms |
5004 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
335 ms |
5004 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
178 ms |
5108 KB |
Output is correct |
12 |
Correct |
184 ms |
5036 KB |
Output is correct |
13 |
Correct |
187 ms |
4940 KB |
Output is correct |
14 |
Correct |
211 ms |
5004 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Incorrect |
335 ms |
5004 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
335 ms |
5004 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
178 ms |
5108 KB |
Output is correct |
12 |
Correct |
184 ms |
5036 KB |
Output is correct |
13 |
Correct |
187 ms |
4940 KB |
Output is correct |
14 |
Correct |
211 ms |
5004 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Incorrect |
335 ms |
5004 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |