Submission #551452

# Submission time Handle Problem Language Result Execution time Memory
551452 2022-04-20T17:52:58 Z toloraia Self Study (JOI22_ho_t2) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
 
const ll linf = 3e18 + 1;
 
bool check(ll a[], ll b[], ll x, ll n, ll m){
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        ll cnta;
        if(b[i] >= a[i])cnta = 0;
        else{
            cnta = x / a[i];
            if(x % a[i]) cnta++;
            cnta = min(cnta, m);
        }
        ll cur = x - a[i] * cnta;
        cnt += cnta;
        if(cnt > n * m) return false;
        if(cur < 0) continue;
        else{
            cnt += cur / b[i];
            if(cur % b[i])cnt++;
            if(cnt > n * m) return false;
        }
    }
    return true;
}
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n; cin >> n;
    ll m; cin >> m;
    ll a[n + 1];
    ll b[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
      	assert (max (a[i],b[i]) <= 1e9)
    }
    ll l = 0, r = linf;
    while(l + 1 < r){
        ll mid = (l + r) / 2;
        if(check(a, b, mid, n, m))l = mid;
        else r = mid;
    }
    cout << l;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:49:5: error: expected ';' before '}' token
   49 |     }
      |     ^