QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750250#9528. New Energy VehicleExFolerCompile Error//C++201.0kb2024-11-15 13:39:542024-11-15 13:39:56

Judging History

This is the latest submission verdict.

  • [2024-11-15 13:39:56]
  • Judged
  • [2024-11-15 13:39:54]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

const int N=1e5+10;
LL a[N],x[N],t[N];
LL man[N];

void solve()
{
    LL n,m;
    cin >> n >> m;
    
    memset(man,0,(sizeof (LL))*(n+5));
    
    LL sum=0;
    for(LL i=1;i<=n;i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for(LL i=1;i<=m;i++)
    {
        cin >> x[i] >> t[i];
    }
    
    LL dis=0,ans=0;
    for(LL i=1;i<=m;i++)
    {
        LL d=x[i]-x[i-1];
        dis+=d;
        if(dis>sum) 
        {
            ans=x[i-1]+(sum-(dis-d));
            break;
        }
        LL bus=min(dis,min(x[i]-man[t[i]],a[t[i]]));
        dis-=bus;
        dis = max(dis , 0) ;
        man[t[i]]=x[i];
    }
    if(dis<=sum) ans=x[m]+(sum-dis);
    
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    
    int T;
    cin >> T;
    while(T--)
    {
        solve();
    }
    
    return 0;
}
/*
1
1 4
1
1 1
2 1
3 1
4 1

*/

Details

answer.code: In function ‘void solve()’:
answer.code:39:18: error: no matching function for call to ‘max(LL&, int)’
   39 |         dis = max(dis , 0) ;
      |               ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:39:18: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   39 |         dis = max(dis , 0) ;
      |               ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:39:18: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
   39 |         dis = max(dis , 0) ;
      |               ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:39:18: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   39 |         dis = max(dis , 0) ;
      |               ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:39:18: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   39 |         dis = max(dis , 0) ;
      |               ~~~^~~~~~~~~