Submission #672125

#TimeUsernameProblemLanguageResultExecution timeMemory
672125infertechno2Schools (IZhO13_school)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll Size=3e5+10; pair<ll,ll> a[Size]; long long ansm[Size],anss[Size]; bool comp(const pair<ll,ll>& A,const pair<ll,ll>& B){ return (A.first-A.second)<(B.first-B.second); } void solve(){ ll n,m,s; cin>>n>>m>>s; for(ll i=1;i<=n;i++){ cin>>a[i].first>>a[i].second; } sort(a+1,a+n+1,comp); priority_queue<ll,vector<ll>,greater<ll>> to_remove; ll ans_for_s=0; for(ll i=1;i<=n;i++){ to_remove.push(a[i].second); ans_for_s+=a[i].second; if(to_remove.size()>s){ ans_for_s-=to_remove.top(); to_remove.pop(); } anss[i]=ans_for_s; } while(!to_remove.empty()){ to_remove.pop(); } ll ans_for_m=0; for(ll i=n;i>0;i--){ to_remove.push(a[i].first); ans_for_m+=a[i].first; if(to_remove.size()>m){ ans_for_m-=to_remove.top(); to_remove.pop(); } ansm[i]=ans_for_m; } ll ans=0; for(ll i=0;i<=n;i++){ ans=max(ans,anss[i]+ansm[i+1]); } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll t=1; while(t--){ solve(); } return 0; }

Compilation message (stderr)

school.cpp: In function 'void solve()':
school.cpp:27:28: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   27 |         if(to_remove.size()>s){
      |            ~~~~~~~~~~~~~~~~^~
school.cpp:40:28: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   40 |         if(to_remove.size()>m){
      |            ~~~~~~~~~~~~~~~~^~
school.cpp:48:38: error: no matching function for call to 'max(ll&, long long int)'
   48 |         ans=max(ans,anss[i]+ansm[i+1]);
      |                                      ^
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 school.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:
school.cpp:48:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   48 |         ans=max(ans,anss[i]+ansm[i+1]);
      |                                      ^
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 school.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:
school.cpp:48:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   48 |         ans=max(ans,anss[i]+ansm[i+1]);
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from school.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:
school.cpp:48:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   48 |         ans=max(ans,anss[i]+ansm[i+1]);
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from school.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:
school.cpp:48:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   48 |         ans=max(ans,anss[i]+ansm[i+1]);
      |                                      ^