# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
529421 |
2022-02-23T02:05:44 Z |
wiwiho |
Self Study (JOI22_ho_t2) |
C++14 |
|
388 ms |
5004 KB |
#include <bits/stdc++.h>
#define iter(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int n;
ll m;
vector<ll> a, b;
ll tans;
bool check(ll mn){
ll cnt = 0;
for(int i = 1; i <= n; i++){
ll need = iceil(mn, a[i]);
assert(need > 0);
if(need <= m){
cnt += m - need;
continue;
}
ll tmp = mn - m * a[i];
cnt -= iceil(tmp, b[i]);
}
//if(cnt >= 0) assert(mn <= tans);
return cnt >= 0;
}
mt19937 rnd(123123);
uniform_int_distribution<int> ud(48763, 123456);
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
a.resize(n + 1);
b.resize(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) cin >> b[i];
//for(int i = 1; i <= n; i++) a[i] = ud(rnd);
//for(int i = 1; i <= n; i++) b[i] = ud(rnd);
for(int i = 1; i <= n; i++) a[i] = max(a[i], b[i]);
//for(int i = 1; i <= 10; i++) cerr << check(i) << " ";
//cerr << "\n";
tans = *min_element(a.begin() + 1, a.end());
//cout << *min_element(a.begin() + 1, a.end()) << "\n";
//return 0;
ll l = 0, r = 1e15;
while(l < r){
ll mid = (l + r + 1) / 2;
if(check(mid)) l = mid;
else r = mid - 1;
}
cout << l << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
5000 KB |
Output is correct |
12 |
Correct |
170 ms |
5000 KB |
Output is correct |
13 |
Correct |
196 ms |
5004 KB |
Output is correct |
14 |
Incorrect |
332 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
89 ms |
2636 KB |
Output is correct |
10 |
Correct |
60 ms |
1868 KB |
Output is correct |
11 |
Correct |
43 ms |
1484 KB |
Output is correct |
12 |
Correct |
42 ms |
1256 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
5 ms |
392 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Incorrect |
388 ms |
5004 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
5000 KB |
Output is correct |
12 |
Correct |
170 ms |
5000 KB |
Output is correct |
13 |
Correct |
196 ms |
5004 KB |
Output is correct |
14 |
Incorrect |
332 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
89 ms |
2636 KB |
Output is correct |
10 |
Correct |
60 ms |
1868 KB |
Output is correct |
11 |
Correct |
43 ms |
1484 KB |
Output is correct |
12 |
Correct |
42 ms |
1256 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
5 ms |
392 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Incorrect |
388 ms |
5004 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
169 ms |
5000 KB |
Output is correct |
12 |
Correct |
170 ms |
5000 KB |
Output is correct |
13 |
Correct |
196 ms |
5004 KB |
Output is correct |
14 |
Incorrect |
332 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |