結果

問題 No.1290 Addition and Subtraction Operation
ユーザー beetbeet
提出日時 2020-11-13 22:17:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 705 ms / 2,000 ms
コード長 1,558 bytes
コンパイル時間 2,232 ms
コンパイル使用メモリ 216,020 KB
実行使用メモリ 10,832 KB
最終ジャッジ日時 2023-09-30 03:09:58
合計ジャッジ時間 20,686 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 20 ms
5,036 KB
testcase_43 AC 19 ms
5,008 KB
testcase_44 AC 20 ms
5,012 KB
testcase_45 AC 20 ms
5,056 KB
testcase_46 AC 20 ms
5,128 KB
testcase_47 AC 20 ms
5,144 KB
testcase_48 AC 20 ms
5,116 KB
testcase_49 AC 20 ms
4,956 KB
testcase_50 AC 19 ms
5,060 KB
testcase_51 AC 19 ms
4,960 KB
testcase_52 AC 19 ms
4,960 KB
testcase_53 AC 19 ms
5,068 KB
testcase_54 AC 18 ms
4,996 KB
testcase_55 AC 20 ms
5,004 KB
testcase_56 AC 19 ms
4,960 KB
testcase_57 AC 385 ms
7,388 KB
testcase_58 AC 576 ms
8,092 KB
testcase_59 AC 367 ms
7,616 KB
testcase_60 AC 687 ms
10,636 KB
testcase_61 AC 689 ms
9,296 KB
testcase_62 AC 705 ms
9,620 KB
testcase_63 AC 578 ms
8,176 KB
testcase_64 AC 51 ms
6,564 KB
testcase_65 AC 230 ms
7,228 KB
testcase_66 AC 667 ms
8,648 KB
testcase_67 AC 674 ms
10,832 KB
testcase_68 AC 705 ms
9,408 KB
testcase_69 AC 575 ms
8,088 KB
testcase_70 AC 520 ms
7,808 KB
testcase_71 AC 644 ms
8,372 KB
testcase_72 AC 249 ms
7,108 KB
testcase_73 AC 687 ms
8,952 KB
testcase_74 AC 19 ms
6,548 KB
testcase_75 AC 160 ms
6,772 KB
testcase_76 AC 524 ms
7,992 KB
testcase_77 AC 633 ms
9,516 KB
testcase_78 AC 597 ms
9,060 KB
testcase_79 AC 369 ms
7,928 KB
testcase_80 AC 632 ms
10,620 KB
testcase_81 AC 628 ms
10,472 KB
testcase_82 AC 529 ms
8,492 KB
testcase_83 AC 635 ms
10,392 KB
testcase_84 AC 627 ms
10,148 KB
testcase_85 AC 234 ms
7,204 KB
testcase_86 AC 55 ms
6,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


template<typename V>
V compress(V vs){
  sort(vs.begin(),vs.end());
  vs.erase(unique(vs.begin(),vs.end()),vs.end());
  return vs;
}
template<typename T>
map<T, int> dict(const vector<T> &vs){
  map<T, int> res;
  for(int i=0;i<(int)vs.size();i++)
    res[vs[i]]=i;
  return res;
}
map<char, int> dict(const string &s){
  return dict(vector<char>(s.begin(),s.end()));
}

//INSERT ABOVE HERE
const int MAX = 1e5+10;
using ll = long long;
ll bs[MAX];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,m;
  cin>>n>>m;
  // auto bs=read(n);
  for(int i=0;i<n;i++) cin>>bs[i];

  vector<int> ls(m),rs(m);
  for(int i=0;i<m;i++) cin>>ls[i]>>rs[i],ls[i]--;

  vector<vector<int>> G(n);
  for(int i=0;i<m;i++)
    G[ls[i]].emplace_back(rs[i]);

  for(int i=0;i<n;i++){
    auto &vs=G[i];
    if(vs.empty()) continue;
    vs=compress(vs);
    for(int j=0;j+1<(int)vs.size();j++)
      G[vs[j]].emplace_back(vs[j+1]);

    if(bs[i]==0) continue;

    int x=i,y=vs[0],z=bs[i];
    for(int j=x;j<y;j++)
      bs[j]+=(j-x)&1?+z:-z;
  }
  for(int i=0;i<n;i++)
    if(bs[i]) drop("NO");
  drop("YES");
  return 0;
}
0