# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526184 | Plurm | Diversity (CEOI21_diversity) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
template <typename T>
class FenwickTree{
public:
T* FT;
int n;
bool negmode;
FenwickTree(int sz = 300000, bool negindex = true){
n = sz+505;
FT = new T[n];
fill(FT, FT+n, (T)0);
negmode = negindex;
}
inline void add(int idx, T amt){
if(negmode) idx += n/2;
while(idx < n){
FT[idx] += amt;
idx += idx & -idx;
}
}
inline T sum(int idx){
if(negmode) idx += n/2;
T ret = (T)0;
while(idx > 0){
ret += FT[idx];
idx -= idx & -idx;
}
return ret;