結果

問題 No.1099 Range Square Sum
ユーザー SSRSSSRS
提出日時 2020-05-17 13:00:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 612 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 168,468 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-02 05:32:24
合計ジャッジ時間 6,584 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  //愚直解
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    int t;
    cin >> t;
    if (t == 1){
      int l, r, x;
      cin >> l >> r >> x;
      l--;
      r--;
      for (int j = l; j <= r; j++){
        A[j] += x;
      }
    }
    if (t == 2){
      int l, r;
      cin >> l >> r;
      long long ans = 0;
      l--;
      r--;
      for (int j = l; j <= r; j++){
        ans += A[j] * A[j];
      }
      cout << ans << endl;
    }
  }
}
0