結果
| 問題 |
No.2812 Plus Minus Blackboard
|
| コンテスト | |
| ユーザー |
Fu_L
|
| 提出日時 | 2024-07-19 21:36:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,083 bytes |
| コンパイル時間 | 3,529 ms |
| コンパイル使用メモリ | 285,816 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 02:13:45 |
| 合計ジャッジ時間 | 5,169 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
int main(void) {
ll n;
cin >> n;
vector<ll> a(n);
vector<ll> pos, neg;
ll ps = 0, ns = 0;
rep(i, 0, n) {
cin >> a[i];
if(a[i] >= 0) {
pos.push_back(a[i]);
ps += a[i];
} else {
neg.push_back(a[i]);
ns += a[i];
}
}
ranges::sort(pos);
ranges::sort(neg);
if(abs(ps) >= abs(ns)) {
ps -= pos.back();
if(abs(ps) <= abs(ns)) {
cout << "Yes" << '\n';
} else {
cout << "No" << '\n';
}
} else {
ns -= neg[0];
if(abs(ps) >= abs(ns)) {
cout << "Yes" << '\n';
} else {
cout << "No" << '\n';
}
}
}
Fu_L