답안 #766713

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
766713 2023-06-26T05:11:51 Z raysh07 Self Study (JOI22_ho_t2) C++17
0 / 100
520 ms 5012 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)4e18
#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]);
            assert(sw >= 0);
            
            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;
}
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 4 ms 396 KB Output is correct
11 Correct 228 ms 5012 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 136 ms 4948 KB Output is correct
14 Incorrect 520 ms 5012 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 4 ms 396 KB Output is correct
11 Correct 228 ms 5012 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 136 ms 4948 KB Output is correct
14 Incorrect 520 ms 5012 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 0 ms 212 KB Output is correct
10 Correct 4 ms 396 KB Output is correct
11 Correct 228 ms 5012 KB Output is correct
12 Correct 224 ms 4948 KB Output is correct
13 Correct 136 ms 4948 KB Output is correct
14 Incorrect 520 ms 5012 KB Output isn't correct
15 Halted 0 ms 0 KB -