/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'void solve(int)':
foo.cc:26:3: error: 'dbg' was not declared in this scope
   26 |   dbg(first);
      |   ^~~

Code

#include <bits/stdc++.h>

using namespace std;

void solve(int cs) {
  int n;
  cin >> n;
  multiset<int> pos, neg;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x >= 0) {
      pos.insert(x);
    } else {
      neg.insert(x);
    }
  }
  int first = 0;
  if (pos.size()) {
    first = *pos.rbegin();
    pos.erase(--pos.end());
  } else {
    first = *neg.rbegin();
    neg.erase(--neg.end());
  }
  dbg(first);
  int64_t ans1 = 0;
  if (pos.size()) {
    ans1 = first - *pos.rbegin();
    pos.erase(--pos.end());
  } else {
    ans1 = first - *neg.rbegin();
    neg.erase(--neg.end());
  }
  if (n == 2) {
    cout << ans1 << "\n";
    return;
  }
  int64_t ans2 = 0;
  if (pos.size()) {
    ans2 = ans1 + *pos.rbegin();
  } else {
    ans2 = ans1 + *neg.rbegin();
  }
  cout << max(ans1, ans2) << "\n";
}

int32_t main() {
  cin.tie(0) -> sync_with_stdio(0);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve(i);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1208 C. Game on Integer
Contest
Educational Round 1
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-14 17:16:53
Judged At
2025-07-14 17:16:53
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes