結果
| 問題 |
No.2812 Plus Minus Blackboard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-19 21:51:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,337 bytes |
| コンパイル時間 | 1,336 ms |
| コンパイル使用メモリ | 166,240 KB |
| 実行使用メモリ | 12,032 KB |
| 最終ジャッジ日時 | 2025-04-09 08:37:50 |
| 合計ジャッジ時間 | 3,293 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "algo/debug.h"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define int long long
void solve() {
int n;
cin >> n;
multiset<int> s, _s;
for (int i = 0, x; i < n; i++) {
cin >> x;
if (x >= 0) {
s.insert(x);
} else {
_s.insert(x);
}
}
while (1) {
if (s.size() > 0 && _s.size() > 0) {
int v1 = *s.begin();
int v2 = *(--_s.end());
int nxt = v1 + v2;
s.erase(s.find(v1));
_s.erase(_s.find(v2));
if (nxt >= 0) {
s.insert(nxt);
} else {
_s.insert(nxt);
}
} else {
if (s.size()) {
if (s.size() == 1) {
cout << "Yes\n";
} else {
int v1 = *s.begin();
int v2 = *(--s.end());
if (v1 == 0 && v2 == 0) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return;
} else {
if (_s.size() == 1) {
cout << "Yes\n";
} else {
cout << "No\n";
}
return;
}
}
}
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
// cerr << "Time elapsed: " << ((long double)clock() / CLOCKS_PER_SEC) << " s.\n";
}