結果

問題 No.2812 Plus Minus Blackboard
ユーザー areik
提出日時 2024-07-19 21:54:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 94,460 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-08 23:42:49
合計ジャッジ時間 2,062 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void _main()’:
main.cpp:61:7: warning: division by zero [-Wdiv-by-zero]
   61 |     1 / 0;
      |     ~~^~~

ソースコード

diff #

#include <algorithm>
#include <atcoder/fenwicktree.hpp>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <utility>
#include <vector>
using namespace std;
using i8 = int8_t;
using i32 = int;
using i64 = long long;
// using i128 = __int128;
using u64 = unsigned long long;
using ll = long long;

void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}

i64 pow(i64 j, i64 n) {
  i64 res = 1;
  while (n > 0) {
    if (n & 1)
      res *= j;
    j *= j;
    n >>= 1;
  }
  return res;
}

using p2 = pair<i64, i64>;
void _main() {
  i64 n;
  cin >> n;
  i64 maxa = 0, maxb = 0;
  i64 cnta = 0, cntb = 0;
  i64 suma = 0, sumb = 0;
  for (i64 i = 0; i < n; i++) {
    i64 a;
    cin >> a;
    if (a < 0) {
      maxa = min(maxa, a);
      suma += a;
      cnta++;
    } else if (a > 0) {
      maxb = max(maxb, a);
      sumb += a;
      cntb++;
    }
  }
  if ((cnta && suma - maxa + sumb >= 0) || (cntb && suma + sumb - maxb <= 0)) {
    cout << "Yes\n";
  } else {
    1 / 0;
    cout << "No\n";
  }
}
0