답안 #703652

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703652 2023-02-28T03:19:10 Z niter Self Study (JOI22_ho_t2) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<long long,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n";
using namespace std;

long long a[300050], b[300050], c[300050];

/*ostream& operator<<(ostream &os, pii XXX){
    cout << "[" << XXX.ff << ", " << XXX.ss << "]";
}*/
void db(){
    cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
    cout << XXX;  db(YYY...);
}

int main(){
    long long n, m, all;
    cin >> n >> m;
    all = n * m;
    loop(i,0,n) cin >> a[i];
    loop(i,0,n) cin >> b[i];
    loop(i,0,n) c[i] = max(a[i], b[i]);
    long long Tr = 1, Fal = 1LL<<60, mid;
    __int128 cost, classes;
    while(Fal - Tr > 1){
        mid = (Tr + Fal) >> 1;
        classes = 0;
        loop(i,0,n){
            cost = mid;
            if(b[i] >= a[i]){
                classes += ((cost-1) / b[i] + 1);
            }
            else{
                classes += min(((cost-1) / a[i] + 1), m);
                cost -= min(((cost-1) / a[i] + 1), m) * a[i];
                if(cost > 0)
                	classes += ((cost-1) / b[i] + 1);
            }
        }
        if(classes > all){
            Fal = mid;
        }
        else{
            Tr = mid;
        }
    }
    cout << Tr << "\n";
    return 0;
}
/*
3 3
19 4 5
2 6 2
*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:42:56: error: no matching function for call to 'min(__int128, long long int&)'
   42 |                 classes += min(((cost-1) / a[i] + 1), m);
      |                                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:42:56: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   42 |                 classes += min(((cost-1) / a[i] + 1), m);
      |                                                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:42:56: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   42 |                 classes += min(((cost-1) / a[i] + 1), m);
      |                                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:42:56: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   42 |                 classes += min(((cost-1) / a[i] + 1), m);
      |                                                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:42:56: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   42 |                 classes += min(((cost-1) / a[i] + 1), m);
      |                                                        ^
Main.cpp:43:53: error: no matching function for call to 'min(__int128, long long int&)'
   43 |                 cost -= min(((cost-1) / a[i] + 1), m) * a[i];
      |                                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:43:53: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   43 |                 cost -= min(((cost-1) / a[i] + 1), m) * a[i];
      |                                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:43:53: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   43 |                 cost -= min(((cost-1) / a[i] + 1), m) * a[i];
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
Main.cpp:43:53: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   43 |                 cost -= min(((cost-1) / a[i] + 1), m) * a[i];
      |                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
Main.cpp:43:53: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   43 |                 cost -= min(((cost-1) / a[i] + 1), m) * a[i];
      |                                                     ^