编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#46890 #1002. B. 说服合伙人 Compile Error 0 0 ms 0 K C++ / 717 B 20183400682 2020-12-17 21:43:45
显示原始代码
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

pair<uint64_t, uint64_t> card[100001];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> card[i].first >> card[i].second;
    }
    sort(card + 1, card + n + 1, greater<pair<uint64_t, uint64_t>>());

    multiset<uint64_t> ans;
    for (int i = 2; i <= n; i++) {
        if (i & 1) {
            if (!ans.empty() && *ans.begin() < card[i].second)
                ans.erase(ans.begin()), ans.insert(card[i].second);
        } else {
            ans.insert(card[i].second);
        }
    }

    uint64_t sum = 0;
    for (auto v : ans) sum += v;
    cout << sum << endl;
}

编译信息

/sandbox/1/a.cpp:7:6: error: 'uint64_t' was not declared in this scope
 pair<uint64_t, uint64_t> card[100001];
      ^~~~~~~~
/sandbox/1/a.cpp:7:6: note: suggested alternative: 'u_int64_t'
 pair<uint64_t, uint64_t> card[100001];
      ^~~~~~~~
      u_int64_t
/sandbox/1/a.cpp:7:16: error: 'uint64_t' was not declared in this scope
 pair<uint64_t, uint64_t> card[100001];
                ^~~~~~~~
/sandbox/1/a.cpp:7:16: note: suggested alternative: 'u_int64_t'
 pair<uint64_t, uint64_t> card[100001];
                ^~~~~~~~
                u_int64_t
/sandbox/1/a.cpp:7:24: error: template argument 1 is invalid
 pair<uint64_t, uint64_t> card[100001];
                        ^
/sandbox/1/a.cpp:7:24: error: template argument 2 is invalid
/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:13:24: error: request for member 'first' in 'card[i]', which is of non-class type 'int'
         cin >> card[i].first >> card[i].second;
                        ^~~~~
/sandbox/1/a.cpp:13:41: error: request for member 'second' in 'card[i]', which is of non-class type 'int'
         cin >> card[i].first >> card[i].second;
                                         ^~~~~~
/sandbox/1/a.cpp:15:47: error: 'uint64_t' was not declared in this scope
     sort(card + 1, card + n + 1, greater<pair<uint64_t, uint64_t>>());
                                               ^~~~~~~~
/sandbox/1/a.cpp:15:47: note: suggested alternative: 'u_int64_t'
     sort(card + 1, card + n + 1, greater<pair<uint64_t, uint64_t>>());
                                               ^~~~~~~~
                                               u_int64_t
/sandbox/1/a.cpp:15:68: error: template argument 1 is invalid
     sort(card + 1, card + n + 1, greater<pair<uint64_t, uint64_t>>());
                                                                    ^
/sandbox/1/a.cpp:15:68: error: template argument 2 is invalid
/sandbox/1/a.cpp:15:42: error: template argument 1 is invalid
     sort(card + 1, card + n + 1, greater<pair<uint64_t, uint64_t>>());
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:17:22: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Key, class _Compare, class _Alloc> class std::multiset'
     multiset<uint64_t> ans;
                      ^
/sandbox/1/a.cpp:17:22: note:   expected a type, got 'uint64_t'
/sandbox/1/a.cpp:17:22: error: template argument 2 is invalid
/sandbox/1/a.cpp:17:22: error: template argument 3 is invalid
/sandbox/1/a.cpp:20:22: error: request for member 'empty' in 'ans', which is of non-class type 'int'
             if (!ans.empty() && *ans.begin() < card[i].second)
                      ^~~~~
/sandbox/1/a.cpp:20:38: error: request for member 'begin' in 'ans', which is of non-class type 'int'
             if (!ans.empty() && *ans.begin() < card[i].second)
                                      ^~~~~
/sandbox/1/a.cpp:20:56: error: request for member 'second' in 'card[i]', which is of non-class type 'int'
             if (!ans.empty() && *ans.begin() < card[i].second)
                                                        ^~~~~~
/sandbox/1/a.cpp:21:21: error: request for member 'erase' in 'ans', which is of non-class type 'int'
                 ans.erase(ans.begin()), ans.insert(card[i].second);
                     ^~~~~
/sandbox/1/a.cpp:21:31: error: request for member 'begin' in 'ans', which is of non-class type 'int'
                 ans.erase(ans.begin()), ans.insert(card[i].second);
                               ^~~~~
/sandbox/1/a.cpp:21:45: error: request for member 'insert' in 'ans', which is of non-class type 'int'
                 ans.erase(ans.begin()), ans.insert(card[i].second);
                                             ^~~~~~
/sandbox/1/a.cpp:21:60: error: request for member 'second' in 'card[i]', which is of non-class type 'int'
                 ans.erase(ans.begin()), ans.insert(card[i].second);
                                                            ^~~~~~
/sandbox/1/a.cpp:23:17: error: request for member 'insert' in 'ans', which is of non-class type 'int'
             ans.insert(card[i].second);
                 ^~~~~~
/sandbox/1/a.cpp:23:32: error: request for member 'second' in 'card[i]', which is of non-class type 'int'
             ans.insert(card[i].second);
                                ^~~~~~
/sandbox/1/a.cpp:27:13: error: expected ';' before 'sum'
     uint64_t sum = 0;
             ^~~~
             ;
/sandbox/1/a.cpp:28:15: error: 'v' does not name a type
     for (auto v : ans) sum += v;
               ^
/sandbox/1/a.cpp:28:33: error: expected ';' before 'cout'
     for (auto v : ans) sum += v;
                                 ^
                                 ;
     cout << sum << endl;
     ~~~~                         
/sandbox/1/a.cpp:29:13: error: 'sum' was not declared in this scope
     cout << sum << endl;
             ^~~
/sandbox/1/a.cpp:30:1: error: expected primary-expression before '}' token
 }
 ^
/sandbox/1/a.cpp:29:25: error: expected ')' before '}' token
     cout << sum << endl;
                         ^
                         )
 }
 ~                        
/sandbox/1/a.cpp:28:9: note: to match this '('
     for (auto v : ans) sum += v;
         ^
/sandbox/1/a.cpp:30:1: error: expected primary-expression before '}' token
 }
 ^