QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#525136#7523. Partially Free Mealrxzfn639Compile Error//C++981.2kb2024-08-20 13:17:022024-08-20 13:17:03

Judging History

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

  • [2024-08-20 13:17:03]
  • 评测
  • [2024-08-20 13:17:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 P = 998244353;
void solve() {
    int n;
    cin >> n;
    vector<i64> a(n), b(n), ans(n);
    i64 res = 0, mxb = 0;
    set<pair<i64, int>> sa, sb;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        sa.insert({a[i], i});
        sb.insert({b[i], i});
        res += a[i];
        mxb = max(mxb, b[i]);
    }
    res += mxb;
    ans[n - 1] = res;
    for (int i = n - 2; i >= 0; i--) {
        auto tmp1 = *sa.rbegin();
        auto tmp2 = *sb.rbegin();
        auto tmp3 = *prev(prev(sb.end()));
        i64 res1 = tmp1.first, res2 = a[tmp2.second] + b[tmp2.second] - b[tmp3.second];
        if (res1 > res2) {
            ans[i] = ans[i + 1] - res1;
            sa.erase(tmp1);
            sb.erase({b[tmp1.second], tmp1.second});
        } else {
            ans[i] = ans[i + 1] - res2;
            sb.erase(tmp2);
            sa.erase({a[tmp2.second], tmp2.second});
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int t = 1; 
    // cin >> t;
    while(t--) solve();
    return 0;
}
/*
3
2 5
4 3
3 7
*/

詳細信息

answer.code:3:7: error: expected nested-name-specifier before ‘i64’
    3 | using i64 = long long;
      |       ^~~
answer.code:4:7: error: ‘i64’ does not name a type
    4 | const i64 P = 998244353;
      |       ^~~
answer.code: In function ‘void solve()’:
answer.code:8:12: error: ‘i64’ was not declared in this scope
    8 |     vector<i64> a(n), b(n), ans(n);
      |            ^~~
answer.code:8:15: error: template argument 1 is invalid
    8 |     vector<i64> a(n), b(n), ans(n);
      |               ^
answer.code:8:15: error: template argument 2 is invalid
answer.code:9:8: error: expected ‘;’ before ‘res’
    9 |     i64 res = 0, mxb = 0;
      |        ^~~~
      |        ;
answer.code:10:22: error: ‘>>’ should be ‘> >’ within a nested template argument list
   10 |     set<pair<i64, int>> sa, sb;
      |                      ^~
      |                      > >
answer.code:10:22: error: template argument 1 is invalid
answer.code:10:22: error: template argument 2 is invalid
answer.code:10:22: error: template argument 3 is invalid
answer.code:12:17: error: invalid types ‘int[int]’ for array subscript
   12 |         cin >> a[i] >> b[i];
      |                 ^
answer.code:12:25: error: invalid types ‘int[int]’ for array subscript
   12 |         cin >> a[i] >> b[i];
      |                         ^
answer.code:13:12: error: request for member ‘insert’ in ‘sa’, which is of non-class type ‘int’
   13 |         sa.insert({a[i], i});
      |            ^~~~~~
answer.code:13:19: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   13 |         sa.insert({a[i], i});
      |                   ^
answer.code:13:21: error: invalid types ‘int[int]’ for array subscript
   13 |         sa.insert({a[i], i});
      |                     ^
answer.code:14:12: error: request for member ‘insert’ in ‘sb’, which is of non-class type ‘int’
   14 |         sb.insert({b[i], i});
      |            ^~~~~~
answer.code:14:19: warning: extended initializer lists only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions]
   14 |         sb.insert({b[i], i});
      |                   ^
answer.code:14:21: error: invalid types ‘int[int]’ for array subscript
   14 |         sb.insert({b[i], i});
      |                     ^
answer.code:15:9: error: ‘res’ was not declared in this scope
   15 |         res += a[i];
      |         ^~~
answer.code:15:17: error: invalid types ‘int[int]’ for array subscript
   15 |         res += a[i];
      |                 ^
answer.code:16:9: error: ‘mxb’ was not declared in this scope
   16 |         mxb = max(mxb, b[i]);
      |         ^~~
answer.code:16:25: error: invalid types ‘int[int]’ for array subscript
   16 |         mxb = max(mxb, b[i]);
      |                         ^
answer.code:18:5: error: ‘res’ was not declared in this scope
   18 |     res += mxb;
      |     ^~~
answer.code:18:12: error: ‘mxb’ was not declared in this scope
   18 |     res += mxb;
      |            ^~~
answer.code:19:8: error: invalid types ‘int[int]’ for array subscript
   19 |     ans[n - 1] = res;
      |        ^
answer.code:21:14: error: ‘tmp1’ does not name a type; did you mean ‘tm’?
   21 |         auto tmp1 = *sa.rbegin();
      |              ^~~~
      |              tm
answer.code:22:14: error: ‘tmp2’ does not name a type; did you mean ‘tm’?
   22 |         auto tmp2 = *sb.rbegin();
      |              ^~~~
      |              tm
answer.code:23:14: error: ‘tmp3’ does not name a type; did you mean ‘tm’?
   23 |         auto tmp3 = *prev(prev(sb.end()));
      |              ^~~~
      |              tm
answer.code:24:12: error: expected ‘;’ before ‘res1’
   24 |         i64 res1 = tmp1.first, res2 = a[tmp2.second] + b[tmp2.second] - b[tmp3.second];
      |            ^~~~~
      |            ;
answer.code:25:13: error: ‘res1’ was not declared in this scope
   25 |         if (res1 > res2) {
      |             ^~~~
answer.code:25:20: error: ‘res2’ was not declared in this scope
   25 |         if (res1 > res2) {
      |                    ^~~~
answer.code:26:16: error: invalid types ‘int[int]’ for array subscript
   26 |             ans[i] = ans[i + 1] - res1;
      |                ^
answer.code:26:25: error: invalid types ‘int[int]’ for array subscript
   26 |             ans[i] = ans[i + 1] - res1;
      |                         ^
answer.code:27:16: error: request for member ‘erase’ in ‘sa’, which is of non-class type ‘int’
   27 |             sa.erase(tmp1);
      |                ^~~~~
answer.code:27:22: error: ‘tmp1’ was not declared in this scope; did you mean ‘tm’?
   27 |             sa.erase(tmp1);
      |                      ^~~~
      |                      tm
answer.code:28:16: error: request for member ‘erase’ in ‘sb’, which is of non-class type ‘int’
   28 |             sb.erase({b[tmp1.second], tmp1.second});
      |                ^~~~~
answer.code:28:22: warning: extended initializer lists only available with...