Submission #828172

# Submission time Handle Problem Language Result Execution time Memory
828172 2023-08-17T06:17:16 Z RaresFelix Self Study (JOI22_ho_t2) C++17
10 / 100
544 ms 11440 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int MN = 300001;
const ll INF = 1e18 + 71;

ll n, m, A[MN], B[MN];
ll mini = INF;

bool ok(ll val) {
    if(!val) return 1;
    ll nr_sar = 0;
    for(int i = 1; i <= n; ++i) {
        if((val - 1) / A[i] + 1 <= m) {
            nr_sar += m - ((val - 1) / A[i] + 1);
        } else {
            nr_sar -= (val - m * A[i] - 1) / B[i] + 1;
        }
    }
    return (nr_sar >= 0);
}

int main() {
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> A[i];
    for(int i = 1; i <= n; ++i) {
        cin >> B[i];
        if(A[i] < B[i]) A[i] = B[i];
    }
    for(int i = 1; i <= n; ++i) mini = min(A[i], mini);
    ll st = 0, dr = INF, mij;
    while(st < dr) {
        mij = st + (dr - st + 1) / 2;
        if(ok(mij)) {
            st = mij;
        }  else dr = mij - 1;
    }
    if(m == 1) {
        cout << mini << "\n";
    } else 
        cout << st << "\n";
    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 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 322 ms 6176 KB Output is correct
12 Correct 327 ms 6252 KB Output is correct
13 Correct 295 ms 6256 KB Output is correct
14 Correct 521 ms 6256 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 544 ms 6156 KB Output is correct
17 Correct 349 ms 11440 KB Output is correct
18 Correct 325 ms 10784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 544 ms 6156 KB Output is correct
3 Correct 349 ms 11440 KB Output is correct
4 Correct 325 ms 10784 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 163 ms 3820 KB Output is correct
14 Correct 120 ms 3020 KB Output is correct
15 Correct 82 ms 2724 KB Output is correct
16 Correct 81 ms 2252 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Incorrect 9 ms 400 KB Output isn't correct
23 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 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 322 ms 6176 KB Output is correct
12 Correct 327 ms 6252 KB Output is correct
13 Correct 295 ms 6256 KB Output is correct
14 Correct 521 ms 6256 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 163 ms 3820 KB Output is correct
24 Correct 120 ms 3020 KB Output is correct
25 Correct 82 ms 2724 KB Output is correct
26 Correct 81 ms 2252 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Incorrect 9 ms 400 KB Output isn't correct
33 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 308 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 163 ms 3820 KB Output is correct
10 Correct 120 ms 3020 KB Output is correct
11 Correct 82 ms 2724 KB Output is correct
12 Correct 81 ms 2252 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 9 ms 400 KB Output isn't correct
19 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 1 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 468 KB Output is correct
11 Correct 322 ms 6176 KB Output is correct
12 Correct 327 ms 6252 KB Output is correct
13 Correct 295 ms 6256 KB Output is correct
14 Correct 521 ms 6256 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 163 ms 3820 KB Output is correct
24 Correct 120 ms 3020 KB Output is correct
25 Correct 82 ms 2724 KB Output is correct
26 Correct 81 ms 2252 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Incorrect 9 ms 400 KB Output isn't correct
33 Halted 0 ms 0 KB -