QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#698055#9528. New Energy VehiclewkrCompile Error//C++142.4kb2024-11-01 17:09:232024-11-01 17:09:25

Judging History

This is the latest submission verdict.

  • [2024-11-01 17:09:25]
  • Judged
  • [2024-11-01 17:09:23]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define close ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const int N = 1e5 + 5;
int tree[N];
int n, m;
int lowbit(int x)
{
    return x & -x;
}
void add(int pos, int val)
{
    while (pos <= n)
    {
        tree[pos] += val;
        pos += lowbit(pos);
    }
}
int query(int x)
{
    int ans = 0;
    while (x >= 1)
    {
        ans += tree[x];
        x -= lowbit(x);
    }
    return ans;
}
int query(int l, int r)
{
    return query(r) - query(l - 1);
}
void update(int pos, int k)
{
    while (pos <= n)
    {
        tree[pos] += k;
        pos += lowbit(pos);
    }
}
int ask(int pos)
{
    int ans = 0;
    while (pos >= 1)
    {
        ans += tree[pos];
        pos -= lowbit(pos);
    }
    return ans;
}
void solved()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        tree[i] = 0;
    }
    vector<int> arr(n + 1, 0);
    int total = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
        total += arr[i];
    }
    vector<int> vis(n + 1, 1);
    brr[0] = {0, 0};
    vector<array<int, 2>> brr(m + 1);
    for (int i = 1; i <= m; i++)
    {
        int x, v;
        cin >> x >> v;
        brr[i] = {x, v};
    }
    sort(brr.begin() + 1, brr.end());
    int cntx = 0;
    map<int, int> mp;
    for (int i = 1; i <= m; i++)
    {
        int dis = brr[i][0] - brr[i - 1][0];
        int id = brr[i][1];
        int v = arr[id];
        if (total < dis)
        {
            break;
        }
        else
        {
            if (v >= dis)
            {
                total += dis;
                int cnt = dis - v;
                for (auto index : mp)
                {
                    if (index != id)
                    {
                        int c = min(mp[index], cnt);
                        cnt -= c;
                        mp[index] -= c;
                        total += c;
                    }
                    if (!cnt)
                    {
                        break;
                    }
                }
            }
            else
            {
                mp[id] = dis - v;
                total += v;
            }
        }
    }
    cout << total << endl;
}

signed main()
{
    close;
    int T;
    cin >> T;
    while (T--)
    {
        solved();
    }
}

Details

answer.code: In function ‘void solved()’:
answer.code:68:5: error: ‘brr’ was not declared in this scope; did you mean ‘arr’?
   68 |     brr[0] = {0, 0};
      |     ^~~
      |     arr
answer.code:96:31: error: no match for ‘operator!=’ (operand types are ‘std::pair<const long long int, long long int>’ and ‘long long int’)
   96 |                     if (index != id)
      |                         ~~~~~ ^~ ~~
      |                         |        |
      |                         |        long long int
      |                         std::pair<const long long int, long long int>
In file included from /usr/include/c++/13/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:181,
                 from answer.code:1:
/usr/include/c++/13/bits/regex.h:1132:5: note: candidate: ‘template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)’
 1132 |     operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1132:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   ‘std::pair<const long long int, long long int>’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1212:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)’
 1212 |     operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1212:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   ‘std::pair<const long long int, long long int>’ is not derived from ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1305:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)’
 1305 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1305:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   ‘std::pair<const long long int, long long int>’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1379:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)’
 1379 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1379:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘long long int’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1473:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)’
 1473 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1473:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   ‘std::pair<const long long int, long long int>’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1547:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)’
 1547 |     operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1547:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   mismatched types ‘const std::__cxx11::sub_match<_BiIter>’ and ‘long long int’
   96 |                     if (index != id)
      |                                  ^~
/usr/include/c++/13/bits/regex.h:1647:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)’
 1647 |     operator!=(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/regex.h:1647:5: note:   template argument deduction/substitution failed:
answer.code:96:34: note:   ‘std::pair<const long long int, long long int>’ is not derived from ‘const std::__cxx11::sub_match<_BiIter>’
   96 |        ...