답안 #331143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
331143 2020-11-27T14:10:16 Z Sho10 Brunhilda’s Birthday (BOI13_brunhilda) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,ans[20000001],a[20000001];
int32_t main(){
CODE_START
n=2e7;
cin>>m;
int q;
cin>>q;
for(int i=1;i<=m;i++)
{
    int x;
    cin>>x;
    for(int j=x;j<=n;j+=x){
        a[j-1]=max(a[j-1],x-1);
    }
}
for(int i=n;i>=1;i--)
{
    a[i]=max(a[i],a[i+1]-1);
}
for(int i=1;i<=m;i++)
{
    if(a[i]&&(ans[i-a[i]]||i-a[i]==0)){
        ans[i]=ans[i-a[i]]+1;
    }
}
while(q--){
    int x;
    cin>>x;
    if(ans[x]){
        cout<<ans[x]<<endl;
    }else cout<<"oo"<<endl;
}
}

Compilation message

brunhilda.cpp: In function 'int32_t main()':
brunhilda.cpp:33:30: error: no matching function for call to 'max(long long int&, int)'
   33 |         a[j-1]=max(a[j-1],x-1);
      |                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from brunhilda.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
brunhilda.cpp:33:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |         a[j-1]=max(a[j-1],x-1);
      |                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from brunhilda.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
brunhilda.cpp:33:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |         a[j-1]=max(a[j-1],x-1);
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from brunhilda.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
brunhilda.cpp:33:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |         a[j-1]=max(a[j-1],x-1);
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from brunhilda.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
brunhilda.cpp:33:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |         a[j-1]=max(a[j-1],x-1);
      |                              ^