結果
| 問題 |
No.2812 Plus Minus Blackboard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-30 10:46:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 962 bytes |
| コンパイル時間 | 1,314 ms |
| コンパイル使用メモリ | 164,804 KB |
| 実行使用メモリ | 11,904 KB |
| 最終ジャッジ日時 | 2025-04-09 08:39:25 |
| 合計ジャッジ時間 | 3,204 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)
int main(){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
ll i,j,k;
ll N;
cin >> N;
multiset<ll> s,t;
bool f=false;
for(i=1;i<=N;i++){
ll x;
cin >> x;
if(x==0 && !f){
s.insert(x);
f=true;
}
else if(x>0) s.insert(x);
else t.insert(-x);
}
ll n=s.size(),m=t.size();
if(m+n==1){
cout <<"Yes" << endl;
return 0;
}
if(n==0 || m==0){
cout <<"No" << endl;
return 0;
}
while(1){
ll a=*s.begin(),b=*t.begin();
ll c=a-b;
s.erase(s.begin());
t.erase(t.begin());
if(c>=0) s.insert(c);
else t.insert(-c);
n=s.size(),m=t.size();
if(n==0 || m==0) break;
}
if(n==1 || m==1) cout <<"Yes" << endl;
else cout <<"No" << endl;
return 0;
}