Submission #562789

# Submission time Handle Problem Language Result Execution time Memory
562789 2022-05-15T10:00:12 Z SSRS Sterilizing Spray (JOI15_sterilizing) C++14
0 / 100
150 ms 1228 KB
#include <bits/stdc++.h>
using namespace std;
struct binary_indexed_tree{
  int N;
  vector<long long> BIT;
  binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
  }
  void add(int i, int x){
    i++;
    while (i <= N){
      BIT[i] += x;
      i += i & -i;
    }
  }
  long long sum(int i){
    long long ans = 0;
    while (i > 0){
      ans += BIT[i];
      i -= i & -i;
    }
    return ans;
  }
  long long sum(int L, int R){
    return sum(R) - sum(L);
  }
};
int main(){
  int N, Q, K;
  cin >> N >> Q >> K;
  vector<int> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  binary_indexed_tree BIT(N);
  for (int i = 0; i < N; i++){
    BIT.add(i, C[i]);
  }
  for (int i = 0; i < Q; i++){
    int S, T, U;
    cin >> S >> T >> U;
    if (S == 1){
      BIT.add(T, -C[T]);
      C[T] = U;
      BIT.add(T, U);
    }
    if (S == 3){
      T--;
      cout << BIT.sum(T, U) << endl;
    }
  }
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 1188 KB Output isn't correct
2 Halted 0 ms 0 KB -