Submission #538664

# Submission time Handle Problem Language Result Execution time Memory
538664 2022-03-17T12:04:39 Z Harry464 Self Study (JOI22_ho_t2) C++14
0 / 100
607 ms 4992 KB
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){

    ll n, m;
    cin >> n >> m; 

    vector <ll> a(n);
    vector <ll> b(n);

    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    for (int i = 0; i < n; i++)
        a[i] = max(a[i], b[i]);

    ll l = 1, r = 1000000000000000001;
    
    ll granica = n*m;

    while (l < r){

        ll mid = (l+r)/2;

        ll potrebno = (ll) 0;

        for (int i = 0; i < n; i++){

           ll maksa =  mid/a[i];
           if (mid%a[i] != 0)
            maksa++;
           potrebno += min(maksa, m);
           ll iskor = min(maksa, m);

           ll maksb = (mid- iskor*a[i])/b[i];
           if(mid-iskor*a[i] < 0)
            continue;
           if((mid - iskor*a[i])%b[i] != 0)
            maksb++;
           potrebno += maksb;

        }

        if (potrebno <= granica)
          l = mid + 1;
        else
          r = mid;

    }

    cout << l - 1;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 0 ms 212 KB Output is correct
10 Correct 7 ms 360 KB Output is correct
11 Correct 441 ms 4980 KB Output is correct
12 Correct 404 ms 4948 KB Output is correct
13 Correct 384 ms 4984 KB Output is correct
14 Incorrect 607 ms 4992 KB Output isn't correct
15 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 0 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 0 ms 212 KB Output is correct
9 Correct 219 ms 2644 KB Output is correct
10 Correct 146 ms 1856 KB Output is correct
11 Correct 102 ms 1468 KB Output is correct
12 Correct 82 ms 1236 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 11 ms 368 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 0 ms 212 KB Output is correct
10 Correct 7 ms 360 KB Output is correct
11 Correct 441 ms 4980 KB Output is correct
12 Correct 404 ms 4948 KB Output is correct
13 Correct 384 ms 4984 KB Output is correct
14 Incorrect 607 ms 4992 KB Output isn't correct
15 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 0 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 0 ms 212 KB Output is correct
9 Correct 219 ms 2644 KB Output is correct
10 Correct 146 ms 1856 KB Output is correct
11 Correct 102 ms 1468 KB Output is correct
12 Correct 82 ms 1236 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 11 ms 368 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 0 ms 212 KB Output is correct
10 Correct 7 ms 360 KB Output is correct
11 Correct 441 ms 4980 KB Output is correct
12 Correct 404 ms 4948 KB Output is correct
13 Correct 384 ms 4984 KB Output is correct
14 Incorrect 607 ms 4992 KB Output isn't correct
15 Halted 0 ms 0 KB -