結果

問題 No.1000 Point Add and Array Add
ユーザー Strorkis
提出日時 2020-02-28 22:46:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 729 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 70,592 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-10-13 18:37:35
合計ジャッジ時間 8,562 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 TLE * 2 -- * 5
権限があれば一括ダウンロードができます

ソースコード

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