Language: C++

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int64_t MOD=10000007;

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  vector<pair<int,int>> S(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    S,at(i)= make_pair(b,a);
  }
  sort(S.begin(), S.end());
  reverse(S.begin(), S.end());
  vector<int> D;
  bool finished=false;
  for(int i=0;i<M;i++){
    for(int j=0;j<S.at(i).second){
      D.push_back(S.at(i).first);
      if(D.size()>=A.size()){
        finished=true;
        break;
      }
    }
    if(finished) break;
  }
  
  for(int i=0;i<min(N,D.size());i++){
    if(A.at(i)<=D.at(i)) A.at(i)=D.at(i);
    else break;
  }
  int64_t total=0;
  for(int i=0;i<N;i++){
    total+=A.at(i);
  }
  cout<<total;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:7: error: 'at' was not declared in this scope; did you mean 'a'?
   16 |     S,at(i)= make_pair(b,a);
      |       ^~
      |       a
a.cc:23:33: error: expected ';' before ')' token
   23 |     for(int j=0;j<S.at(i).second){
      |                                 ^
      |                                 ;
a.cc:33:20: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   33 |   for(int i=0;i<min(N,D.size());i++){
      |                 ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   33 |   for(int i=0;i<min(N,D.size());i++){
      |                 ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:33:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |   for(int i=0;i<min(N,D.size());i++){
      |                 ~~~^~~~~~~~~~~~