Submission #766724

# Submission time Handle Problem Language Result Execution time Memory
766724 2023-06-26T05:22:04 Z raysh07 Self Study (JOI22_ho_t2) C++17
62 / 100
104 ms 8140 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)1e15
#define f first
#define s second

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void Solve() 
{
    int n, m; cin >> n >> m;
    vector <int> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;
    
    int l = 0, r = INF;
    while (r != l){
        int mid = (l + r + 1) / 2;
        
        int use = 0, need = 0;
        for (int i = 0; i < n; i++){
            if (a[i] <= b[i]) {
                need += (mid + b[i] - 1) / b[i];
                if (use + need > n * m) break;
                continue;
            }
            
            int o = (mid + a[i] - 1) / a[i];
            int o1 = 0;
            
            if (o > m){
                o = m;
                int ex = mid - a[i] * o;
                o1 = (ex + b[i] - 1) / b[i];
                //assert(o1 >= 0);
                
            }
            
            int ex = a[i] * o + b[i] * o1 - mid;
            assert(ex >= 0);
            int sw = ex / (a[i] - b[i]);
            
            
            if (sw > o) sw = o;
            
            o -= sw;
            o1 += sw;
            use += o;
            need += o1;
            if (use + need > n * m) break;
        }
        
        if (use + need > n * m) r = mid - 1;
        else l = mid;
    }
    
    cout << l << "\n";
}

int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
  //  cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        //cout << "Case #" << i << ": ";
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 104 ms 5012 KB Output is correct
13 Correct 69 ms 5020 KB Output is correct
14 Correct 83 ms 5008 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 27 ms 6100 KB Output is correct
17 Correct 84 ms 8136 KB Output is correct
18 Correct 84 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 27 ms 6100 KB Output is correct
3 Correct 84 ms 8136 KB Output is correct
4 Correct 84 ms 8140 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 42 ms 2644 KB Output is correct
14 Correct 28 ms 1876 KB Output is correct
15 Correct 21 ms 1516 KB Output is correct
16 Correct 18 ms 1280 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 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 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 104 ms 5012 KB Output is correct
13 Correct 69 ms 5020 KB Output is correct
14 Correct 83 ms 5008 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 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 42 ms 2644 KB Output is correct
24 Correct 28 ms 1876 KB Output is correct
25 Correct 21 ms 1516 KB Output is correct
26 Correct 18 ms 1280 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 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 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 500 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 27 ms 6100 KB Output is correct
36 Correct 84 ms 8136 KB Output is correct
37 Correct 84 ms 8140 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 4 ms 572 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 22 ms 2132 KB Output is correct
49 Correct 0 ms 328 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 3 ms 492 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 55 ms 5464 KB Output is correct
56 Correct 26 ms 3156 KB Output is correct
57 Correct 31 ms 3172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 42 ms 2644 KB Output is correct
10 Correct 28 ms 1876 KB Output is correct
11 Correct 21 ms 1516 KB Output is correct
12 Correct 18 ms 1280 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 500 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 27 ms 6100 KB Output is correct
22 Correct 84 ms 8136 KB Output is correct
23 Correct 84 ms 8140 KB Output is correct
24 Incorrect 25 ms 1944 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 104 ms 5012 KB Output is correct
13 Correct 69 ms 5020 KB Output is correct
14 Correct 83 ms 5008 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 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 42 ms 2644 KB Output is correct
24 Correct 28 ms 1876 KB Output is correct
25 Correct 21 ms 1516 KB Output is correct
26 Correct 18 ms 1280 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 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 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 500 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 4 ms 572 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 22 ms 2132 KB Output is correct
45 Correct 0 ms 328 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 492 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 55 ms 5464 KB Output is correct
52 Correct 26 ms 3156 KB Output is correct
53 Correct 31 ms 3172 KB Output is correct
54 Incorrect 25 ms 1944 KB Output isn't correct
55 Halted 0 ms 0 KB -