답안 #465031

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
465031 2021-08-14T21:31:58 Z Deepesson Snowball (JOI21_ho_t2) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
///Bola de neve
#define MAX 2000005
long long valores[MAX][2];
bool dir[MAX];
int main()
{
    int N,Q;
    std::cin>>N>>Q;
    long long array[N];for(auto&x:array)std::cin>>x;
    for(auto&x:array) x += 1LL<<30LL;
    long long left=0,right=0,pos=0;
    for(int i=0;i!=Q;++i){
        long long D;
        std::cin>>D;
        pos+=D;
        if(pos<0){
            left=std::max(left,abs(pos));
            dir[i]=true;
        }else {
            right=std::max(right,abs(pos));
        }
        valores[i][0]=left;
        valores[i][1]=right;
    }
    long long resultados[N]={};
    resultados[0]+=left;
    resultados[N-1]+=right;
    for(int i=1;i!=N;++i){
        ///i-1 eh esquerda, se referindo a direita
        ///i eh a direita, e ira para a esquerda
        /// i-1 -> Direita     Esquerda <- i
        long long obj = array[i]-array[i-1];
        if(valores[Q-1][0]+valores[Q-1][1]>obj){
            int l=0,r=Q-1;
            while(l<r){
                int m = (l+r)/2;
                long long val = valores[m][0]+valores[m][1];
                if(val>=obj){
                    r=m;
                }else l=m+1;
            }

            long long a = valores[l][0]; ///Esquerda
            long long b = valores[l][1]; ///Direita
            if(a+b==obj){
                resultados[i-1]+=b;
                resultados[i]+=a;
            }else {
                long long dif = (a+b)-(obj);
                if(dir[l]){///Para a esquerda
                    a-=dif;
                }else {///Para a direita
                    b-=dif;
                }
                resultados[i-1]+=b;
                resultados[i]+=a;
            }

        }else {
            resultados[i-1]+=right;
            resultados[i]+=left;
        }
    }
    for(auto&x:resultados)std::cout<<x<<"\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:18:40: error: no matching function for call to 'max(long long int&, int)'
   18 |             left=std::max(left,abs(pos));
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:18:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |             left=std::max(left,abs(pos));
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:18:40: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |             left=std::max(left,abs(pos));
      |                                        ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:18:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             left=std::max(left,abs(pos));
      |                                        ^
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:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:18:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             left=std::max(left,abs(pos));
      |                                        ^
Main.cpp:21:42: error: no matching function for call to 'max(long long int&, int)'
   21 |             right=std::max(right,abs(pos));
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
Main.cpp:21:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |             right=std::max(right,abs(pos));
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
Main.cpp:21:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |             right=std::max(right,abs(pos));
      |                                          ^
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:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
Main.cpp:21:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |             right=std::max(right,abs(pos));
      |                                          ^
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:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
Main.cpp:21:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |             right=std::max(right,abs(pos));
      |                                          ^