답안 #869970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869970 2023-11-06T13:01:00 Z boris_mihov Self Study (JOI22_ho_t2) C++17
컴파일 오류
0 ms 0 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
 
typedef long long llong;
const int MAXN = 300000 + 10;
const llong INF = 1e18;
 
llong n, m;
llong a[MAXN], b[MAXN];
llong achieved[MAXN];
 
bool check(llong value)
{
    llong freeB = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        llong currLections = std::min(m, (value / a[i] + ((value % a[i]) > 0)));
        if (value <= m * a[i]) freeB += m - currLections;
        else
        {
            llong moreLections = (value - m * a[i]) / b[i] + (((value - m * a[i]) % b[i]) > 0);
            freeB -= moreLections;
        }
    }
 
    return freeB >= 0;
}
 
void solve()
{
    llong min = INF;
    llong sum = 0;
 
    for (int i = 1 ; i <= n ; ++i)
    {
        min = std::min(min, m * a[i]);
        sum += m * a[i];
    }
    
    sum /= n;
    llong l = min, r = max + 1, mid;
    while (l < r - 1)
    {
        mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
 
    std::cout << l << '\n';
}
 
void read()
{
    std::cin >> n >> m;
    for (int i = 1 ; i <= n ; ++i) 
    {
        std::cin >> a[i];
    }
 
    for (int i = 1 ; i <= n ; ++i) 
    {
        std::cin >> b[i];
        a[i] = std::max(a[i], b[i]);
    }
}
 
void fastIO()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}
 
int main()
{
    fastIO();
    read();
    solve();
 
    return 0;
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:43:24: error: 'max' was not declared in this scope; did you mean 'std::max'?
   43 |     llong l = min, r = max + 1, mid;
      |                        ^~~
      |                        std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Main.cpp:46:9: error: 'mid' was not declared in this scope; did you mean 'min'?
   46 |         mid = (l + r) / 2;
      |         ^~~
      |         min