// Problem: C. They Are Everywhere // Contest: Codeforces - Codeforces Round 364 (Div. 2) // URL: https://codeforces.com/problemset/problem/701/C // Memory Limit: 256 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h> using namespace std; #define ll long long //# define int long long #define ull unsigned long long #define pii pair<int,int>
#define baoliu(x, y) cout << fixed << setprecision(y) << x #define endl "\n" #define debug1(x) cerr<<x<<" " #define debug2(x) cerr<<x<<endl const int N = 2e5 + 10; const int M = 1e6 + 10; const int inf = 0x3f3f3f3f; const int mod = 998244353; const double eps = 1e-8; int n, m; int a[N];
// Problem: 小红统计区间(hard) // Contest: NowCoder // URL: https://ac.nowcoder.com/acm/contest/73239/F // Memory Limit: 524288 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h> using namespace std; #define ll long long # define int long long #define ull unsigned long long #define pii pair<int,int>
#define baoliu(x, y) cout << fixed << setprecision(y) << x #define endl "\n" #define debug1(x) cerr<<x<<" " #define debug2(x) cerr<<x<<endl const int N = 2e5 + 10; const int M = 1e6 + 10; const int inf = 0x3f3f3f3f; const int mod = 998244353; const double eps = 1e-8; int n, m; int a[N]; vector<int>lan; template <typename T> struct Fenwick { int n; std::vector<T> a; Fenwick(int n_ = 0) { init(n_); } void init(int n_) { n = n_; a.assign(n, T{}); /* T{}是一种初始化T类型对象的方式,它使用了花括号初始化列表进行数值初始化。 对于大多数内置数据类型(如整数、浮点数),这将初始化为0。 */
} void add(int x, const T &v) { for (int i = x; i <=n-1; i += i & -i) { a[i] = a[i] + v; } } T sum(int x) { T ans{}; for (int i = x; i > 0; i -= i & -i) { ans = ans + a[i]; } return ans; } T rangeSum(int l, int r) {//要传入l-1 //待优化:直接给个vector记录前缀和 return sum(r) - sum(l); } int select(const T &k) {//寻找最后一个使得前缀和小于等于 k 的位置。 int x = 0; T cur{}; for (int i = 1 << std::__lg(n-1); i; i /= 2) {//GCC if (x + i <= n-1 && cur + a[x + i] <= k) { x += i; cur = cur + a[x]; } } return x; } };