結果

問題 No.1290 Addition and Subtraction Operation
ユーザー chocoruskchocorusk
提出日時 2020-11-13 22:49:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,425 bytes
コンパイル時間 1,338 ms
コンパイル使用メモリ 131,284 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2023-09-30 03:50:51
合計ジャッジ時間 7,243 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,048 KB
testcase_01 AC 3 ms
7,340 KB
testcase_02 AC 3 ms
6,884 KB
testcase_03 AC 3 ms
7,076 KB
testcase_04 AC 4 ms
6,916 KB
testcase_05 AC 3 ms
6,608 KB
testcase_06 AC 3 ms
6,852 KB
testcase_07 AC 3 ms
7,784 KB
testcase_08 AC 3 ms
6,660 KB
testcase_09 AC 3 ms
7,068 KB
testcase_10 AC 4 ms
7,100 KB
testcase_11 AC 3 ms
6,648 KB
testcase_12 AC 3 ms
6,916 KB
testcase_13 AC 3 ms
7,200 KB
testcase_14 AC 3 ms
6,692 KB
testcase_15 AC 3 ms
6,828 KB
testcase_16 AC 4 ms
7,308 KB
testcase_17 AC 3 ms
7,480 KB
testcase_18 AC 3 ms
6,376 KB
testcase_19 AC 3 ms
6,928 KB
testcase_20 AC 3 ms
7,176 KB
testcase_21 AC 3 ms
6,580 KB
testcase_22 AC 3 ms
7,656 KB
testcase_23 AC 3 ms
7,860 KB
testcase_24 AC 3 ms
7,296 KB
testcase_25 AC 3 ms
6,608 KB
testcase_26 AC 3 ms
7,568 KB
testcase_27 AC 3 ms
6,472 KB
testcase_28 AC 2 ms
6,652 KB
testcase_29 AC 2 ms
6,732 KB
testcase_30 AC 2 ms
6,856 KB
testcase_31 AC 2 ms
7,312 KB
testcase_32 AC 2 ms
7,020 KB
testcase_33 AC 3 ms
6,544 KB
testcase_34 AC 3 ms
7,164 KB
testcase_35 AC 3 ms
6,876 KB
testcase_36 AC 2 ms
6,884 KB
testcase_37 AC 2 ms
7,332 KB
testcase_38 AC 2 ms
7,808 KB
testcase_39 AC 3 ms
6,640 KB
testcase_40 AC 3 ms
7,688 KB
testcase_41 AC 2 ms
6,628 KB
testcase_42 AC 41 ms
8,672 KB
testcase_43 AC 40 ms
8,832 KB
testcase_44 AC 41 ms
8,524 KB
testcase_45 AC 41 ms
8,592 KB
testcase_46 AC 41 ms
8,620 KB
testcase_47 AC 41 ms
8,060 KB
testcase_48 AC 41 ms
8,900 KB
testcase_49 AC 42 ms
8,636 KB
testcase_50 AC 41 ms
9,084 KB
testcase_51 AC 42 ms
8,872 KB
testcase_52 AC 41 ms
8,484 KB
testcase_53 AC 41 ms
8,400 KB
testcase_54 AC 42 ms
8,752 KB
testcase_55 AC 42 ms
8,844 KB
testcase_56 AC 41 ms
8,356 KB
testcase_57 AC 36 ms
8,792 KB
testcase_58 AC 48 ms
9,720 KB
testcase_59 AC 34 ms
8,796 KB
testcase_60 AC 87 ms
11,448 KB
testcase_61 AC 68 ms
10,508 KB
testcase_62 AC 73 ms
10,936 KB
testcase_63 AC 47 ms
9,384 KB
testcase_64 AC 21 ms
7,480 KB
testcase_65 AC 28 ms
8,184 KB
testcase_66 AC 55 ms
9,844 KB
testcase_67 AC 89 ms
11,712 KB
testcase_68 AC 66 ms
10,504 KB
testcase_69 AC 47 ms
9,596 KB
testcase_70 AC 45 ms
9,200 KB
testcase_71 AC 53 ms
9,720 KB
testcase_72 AC 30 ms
8,380 KB
testcase_73 AC 61 ms
10,264 KB
testcase_74 AC 19 ms
7,676 KB
testcase_75 AC 26 ms
7,920 KB
testcase_76 AC 46 ms
9,384 KB
testcase_77 AC 92 ms
10,640 KB
testcase_78 AC 85 ms
10,276 KB
testcase_79 AC 62 ms
9,088 KB
testcase_80 AC 106 ms
11,488 KB
testcase_81 AC 107 ms
11,584 KB
testcase_82 AC 73 ms
9,740 KB
testcase_83 AC 102 ms
11,444 KB
testcase_84 AC 92 ms
10,812 KB
testcase_85 AC 50 ms
9,088 KB
testcase_86 AC 39 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    ll b[100010];
    for(int i=0; i<n; i++){
        cin>>b[i];
        if(i&1) b[i]=-b[i];
    }
    ll d[100010];
    for(int i=1; i<n; i++){
        d[i]=b[i]-b[i-1];
    }
    d[0]=b[0], d[n]=-b[n-1];
    int l[100010], r[100010];
    vector<int> g[100010];
    for(int i=0; i<m; i++){
        cin>>l[i]>>r[i];
        l[i]--;
        g[l[i]].push_back(r[i]);
        g[r[i]].push_back(l[i]);
    }
    bool used[100010]={};
    auto dfs=[&](auto dfs, int x, ll &s)->void{
        s+=d[x];
        used[x]=1;
        for(auto y:g[x]){
            if(!used[y]){
                dfs(dfs, y, s);
            }
        }
    };
    for(int i=0; i<=n; i++){
        if(used[i]) continue;
        ll s=0;
        dfs(dfs, i, s);
        if(s!=0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}
0