結果

問題 No.876 Range Compress Query
ユーザー ei1333333ei1333333
提出日時 2019-09-06 23:13:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,842 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 3,237 ms
コンパイル使用メモリ 212,216 KB
実行使用メモリ 4,428 KB
最終ジャッジ日時 2023-09-07 02:28:05
合計ジャッジ時間 13,969 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 952 ms
4,384 KB
testcase_12 AC 683 ms
4,380 KB
testcase_13 AC 755 ms
4,384 KB
testcase_14 AC 941 ms
4,380 KB
testcase_15 AC 670 ms
4,428 KB
testcase_16 AC 1,743 ms
4,384 KB
testcase_17 AC 1,772 ms
4,384 KB
testcase_18 AC 1,842 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// とおってー!

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;


int main() {
  int N, Q;
  int64 A[100000];
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for(int i = 0; i < Q; i++) {
    int a, b, c, d;
    scanf("%d %d %d", &a, &b, &c);
    --b;
    if(a == 1) {
      scanf("%d", &d);
      for(int j = b; j < c; j++) A[j] += d;
    } else {
      int ret = 0;
      for(int j = b; j < c - 1; j++) ret += A[j] != A[j + 1];
      printf("%d\n", ret + 1);
    }
  }
}
0