Submission #766710

# Submission time Handle Problem Language Result Execution time Memory
766710 2023-06-26T05:09:42 Z raysh07 Self Study (JOI22_ho_t2) C++17
0 / 100
503 ms 5016 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)1e18
#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];
                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];
            }
            
            int ex = a[i] * o + b[i] * o1 - mid;
            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) 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 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 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 1 ms 268 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 217 ms 5016 KB Output is correct
12 Correct 212 ms 4948 KB Output is correct
13 Correct 134 ms 4948 KB Output is correct
14 Incorrect 503 ms 5008 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 8
2 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 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 1 ms 268 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 217 ms 5016 KB Output is correct
12 Correct 212 ms 4948 KB Output is correct
13 Correct 134 ms 4948 KB Output is correct
14 Incorrect 503 ms 5008 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 8
2 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 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 1 ms 268 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 217 ms 5016 KB Output is correct
12 Correct 212 ms 4948 KB Output is correct
13 Correct 134 ms 4948 KB Output is correct
14 Incorrect 503 ms 5008 KB Output isn't correct
15 Halted 0 ms 0 KB -