QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302617#2734. Professional NetworkCamillusCompile Error//C++201.1kb2024-01-11 00:50:582024-01-11 00:50:59

Judging History

你现在查看的是最新测评结果

  • [2024-01-11 00:50:59]
  • 评测
  • [2024-01-11 00:50:58]
  • 提交

answer

#include "bits/stdc++.h"

using ll = long long
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }

    auto comp_a = [&a](int i, int j) -> bool {
        return pair(a[i], i) < pair(a[j], j);
    };

    auto comp_b = [&b](int i, int j) -> bool {
        return pair(b[i], i) < pair(b[j], j);
    };

    set<int, decltype(comp_a)> Q_a(comp_a);
    set<int, decltype(comp_b)> Q_b(comp_b);

    for (int i = 0; i < n; i++) {
        Q_a.insert(i);
        Q_b.insert(i);
    }

    int cnt = 0;
    ll sum = 0;

    while (cnt != n) {
        if (a[*Q_a.begin()] <= cnt) {
            int i = *Q_a.begin();
            Q_a.erase(i);
            Q_b.erase(i);
        } else {
            int i = *Q_b.begin();
            sum += b[i];
            Q_a.erase(i);
            Q_b.erase(i);
        }

        cnt += 1;
    }

    cout << sum << '\n';
    return 0;
}

Details

answer.code:3:21: error: expected ‘;’ before ‘using’
    3 | using ll = long long
      |                     ^
      |                     ;
    4 | using namespace std;
      | ~~~~~                
answer.code: In function ‘int main()’:
answer.code:7:5: error: ‘ios’ has not been declared
    7 |     ios::sync_with_stdio(false);
      |     ^~~
answer.code:8:5: error: ‘cin’ was not declared in this scope; did you mean ‘std::cin’?
    8 |     cin.tie(nullptr);
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:75,
                 from answer.code:1:
/usr/include/c++/11/iostream:60:18: note: ‘std::cin’ declared here
   60 |   extern istream cin;           /// Linked to standard input
      |                  ^~~
answer.code:13:5: error: ‘vector’ was not declared in this scope
   13 |     vector<int> a(n);
      |     ^~~~~~
answer.code:13:5: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   ‘std::vector’
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/vector:86:13: note:   ‘std::pmr::vector’
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
answer.code:13:12: error: expected primary-expression before ‘int’
   13 |     vector<int> a(n);
      |            ^~~
answer.code:14:12: error: expected primary-expression before ‘int’
   14 |     vector<int> b(n);
      |            ^~~
answer.code:17:16: error: ‘a’ was not declared in this scope
   17 |         cin >> a[i];
      |                ^
answer.code:18:16: error: ‘b’ was not declared in this scope
   18 |         cin >> b[i];
      |                ^
answer.code:21:21: error: ‘a’ was not declared in this scope
   21 |     auto comp_a = [&a](int i, int j) -> bool {
      |                     ^
answer.code: In lambda function:
answer.code:22:21: error: ‘a’ is not captured
   22 |         return pair(a[i], i) < pair(a[j], j);
      |                     ^
answer.code:21:22: note: the lambda has no capture-default
   21 |     auto comp_a = [&a](int i, int j) -> bool {
      |                      ^
answer.code:21:21: note: ‘<typeprefixerror>a’ declared here
   21 |     auto comp_a = [&a](int i, int j) -> bool {
      |                     ^
answer.code:22:16: error: ‘pair’ was not declared in this scope; did you mean ‘std::pair’?
   22 |         return pair(a[i], i) < pair(a[j], j);
      |                ^~~~
      |                std::pair
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_pair.h:211:12: note: ‘std::pair’ declared here
  211 |     struct pair
      |            ^~~~
answer.code:22:37: error: ‘a’ is not captured
   22 |         return pair(a[i], i) < pair(a[j], j);
      |                                     ^
answer.code:21:22: note: the lambda has no capture-default
   21 |     auto comp_a = [&a](int i, int j) -> bool {
      |                      ^
answer.code:21:21: note: ‘<typeprefixerror>a’ declared here
   21 |     auto comp_a = [&a](int i, int j) -> bool {
      |                     ^
answer.code: In function ‘int main()’:
answer.code:25:21: error: ‘b’ was not declared in this scope
   25 |     auto comp_b = [&b](int i, int j) -> bool {
      |                     ^
answer.code: In lambda function:
answer.code:26:21: error: ‘b’ is not captured
   26 |         return pair(b[i], i) < pair(b[j], j);
      |                     ^
answer.code:25:22: note: the lambda has no capture-default
   25 |     auto comp_b = [&b](int i, int j) -> bool {
      |                      ^
answer.code:25:21: note: ‘<typeprefixerror>b’ declared here
   25 |     auto comp_b = [&b](int i, int j) -> bool {
      |                     ^
answer.code:26:16: error: ‘pair’ was not declared in this scope; did you mean ‘std::pair’?
   26 |         return pair(b[i], i) < pair(b[j], j);
      |                ^~~~
      |                std::pair
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bi...