結果

問題 No.1000 Point Add and Array Add
ユーザー StrorkisStrorkis
提出日時 2020-02-28 22:46:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 729 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 69,488 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2024-04-21 19:55:24
合計ジャッジ時間 7,778 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 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 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 1,674 ms
8,576 KB
testcase_17 AC 1,089 ms
6,400 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, Q; cin >> N >> Q;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  vector<ll> B(N), count(N), check(N);
  for (int i = 0; i < Q; i++) {
    char c; cin >> c;
    int x, y; cin >> x >> y;
    if (c == 'A') {
      x--;
      B[x] += A[x] * (count[x] - check[x]);
      A[x] += y;
      check[x] = count[x];
    }
    else {
      x--; y--;
      for (int j = x; j <= y; j++) count[j]++;
    }
  }

  for (int i = 0; i < N; i++)
    B[i] += A[i] * (count[i] - check[i]);

  cout << B.front();
  for (int i = 1; i < N; i++)
    cout << " " << B[i];
  cout << "\n";
}
0