# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
528130 |
2022-02-19T10:49:34 Z |
doowey |
Self Study (JOI22_ho_t2) |
C++14 |
|
403 ms |
7352 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)3e5 + 10;
ll A[N];
ll B[N];
ll C[N];
int main(){
fastIO;
//freopen("in.txt","r",stdin);
int n;
cin >> n;
ll m;
cin >> m;
for(int i = 1; i <= n; i ++ ){
cin >> A[i];
}
ll maxi = (ll)1e18;
for(int i = 1; i <= n; i ++ ){
cin >> B[i];
A[i] = max(A[i], B[i]);
maxi = min(maxi, A[i]);
}
ll li = 1;
ll ri = (ll)1e16;
ll mid;
ll nd;
while(li + 1 < ri){
mid = (li + ri) / 2;
ll can;
nd = 0;
for(int i = 1; i <= n; i ++ ){
can = (mid + A[i] - 1) / A[i];
if(can < m){
nd += m - can;
C[i] = 0;
}
else{
C[i] = mid - A[i] * 1ll * m;
if(C[i] < 0) C[i] = 0;
}
}
for(int i = 1; i <= n; i ++ ){
if(C[i] > 0){
nd -= (C[i] + B[i] - 1) / B[i];
}
}
if(nd >= 0){
li = mid;
}
else{
ri = mid;
}
}
cout << li << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
440 KB |
Output is correct |
11 |
Correct |
213 ms |
7340 KB |
Output is correct |
12 |
Correct |
203 ms |
7284 KB |
Output is correct |
13 |
Correct |
234 ms |
7352 KB |
Output is correct |
14 |
Incorrect |
403 ms |
7336 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
117 ms |
3836 KB |
Output is correct |
10 |
Correct |
70 ms |
2580 KB |
Output is correct |
11 |
Correct |
52 ms |
2108 KB |
Output is correct |
12 |
Correct |
42 ms |
1712 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Incorrect |
8 ms |
444 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
440 KB |
Output is correct |
11 |
Correct |
213 ms |
7340 KB |
Output is correct |
12 |
Correct |
203 ms |
7284 KB |
Output is correct |
13 |
Correct |
234 ms |
7352 KB |
Output is correct |
14 |
Incorrect |
403 ms |
7336 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
117 ms |
3836 KB |
Output is correct |
10 |
Correct |
70 ms |
2580 KB |
Output is correct |
11 |
Correct |
52 ms |
2108 KB |
Output is correct |
12 |
Correct |
42 ms |
1712 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Incorrect |
8 ms |
444 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
3 ms |
440 KB |
Output is correct |
11 |
Correct |
213 ms |
7340 KB |
Output is correct |
12 |
Correct |
203 ms |
7284 KB |
Output is correct |
13 |
Correct |
234 ms |
7352 KB |
Output is correct |
14 |
Incorrect |
403 ms |
7336 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |