Submission #803714

# Submission time Handle Problem Language Result Execution time Memory
803714 2023-08-03T05:38:06 Z vjudge1 Self Study (JOI22_ho_t2) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 3e5 ;
bool flag1 ;
ll n, m, l = 0, r = (1ll << 61ll), a[N + 1], b[N + 1] ;
signed main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    cin >> n >> m ;
    for(ll i = 1 ; i <= n ; i++)
        cin >> a[i] ;
    for(ll i = 1 ; i <= n ; i++)
    {
        cin >> b[i] ;
        if(a[i] != b[i])
            flag1 = 1 ;
    }
    if(m == 1)
    {
        ll mn = 1e18 ;
        for(ll i = 1 ; i <= n ; i++)
            mn = min(mn, max(a[i], b[i])) ;
        cout << mn << '\n' ;
        return 0 ;
    }
    if(!flag1)
    {
        while(l + 1 < r)
        {
            bool flag = 0 ;
            ll mid = (l + r) / 2, cnt = 0 ;
            for(ll i = 1 ; i <= n ; i++)
            {
                cnt += (mid + b[i] - 1) / b[i] ;
                if(cnt < 0 || (mid + b[i] - 1) / b[i] < 0)
                    flag = 1 ;
            }
            if(cnt > n * m || flag)
                r = mid ;
            else
                l = mid ;
        }
        cout << l ;
        return 0 ;
    }
    while(l + 1 < r)
    {
        bool flag = 0 ;
        ll mid = (l + r) >> 1, cnt = 0 ;
        ll now[N + 1] = {} ;
        for(ll i = 1 ; i <= n ; i++)
            if(a[i] > b[i])
            {
                if(((mid + a[i] + 1) / a[i]) < m)
                {
                    now[i] = ((mid + a[i] + 1) / a[i]) * a[i] ;
                    cnt -= ((mid + a[i] + 1) / a[i]) ;
                }
                else
                {
                    now = m * a[i] ;
                    cnt -= m ;
                }
            }
        for(int i = 1 ; i <= n ; i++)
        {
            if(now[i] >= mid)
                continue ;
            cnt += (mid - now[i] + b[i] - 1) / b[i] ;
            if(cnt < 0 || (mid + b[i] - 1) / b[i] < 0)
                flag = 1 ;
        }
        if(cnt > n * m || flag)
            r = mid ;
        else
            l = mid ;
    }
    return 0 ;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:66:25: error: incompatible types in assignment of 'long long int' to 'long long int [300001]'
   66 |                     now = m * a[i] ;
      |                     ~~~~^~~~~~~~~~