結果

問題 No.2812 Plus Minus Blackboard
ユーザー daiota
提出日時 2024-07-19 22:56:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 814 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 165,616 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2025-04-08 23:44:08
合計ジャッジ時間 3,349 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    for(i=1;i<=N;i++){
    	ll x;
    	cin >> x;
    	if(x>=0) s.insert(x);
    	else t.insert(-x);
    }

    ll n=s.size(),m=t.size();
    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;

}


0