1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &a){ T w=1; a=0; char ch=getchar(); for(;ch < '0' || ch > '9';ch=getchar()) if(ch == '-') w=-1; for(;ch>='0'&&ch<='9';ch=getchar()) a=(a<<3)+(a<<1)+(ch^48); a*=w; } template <typename T> inline void ckmax(T &a, T b){a = a > b ? a : b;} template <typename T> inline void ckmin(T &a, T b){a = a < b ? a : b;} #define fi first #define se second #define pb push_back #define mp make_pair #define pii pair<int, int> #define vi vector<int> #define Debug(x) cout << #x << " = " << x << endl #define For(i,l,r) for (int i = l; i <= r; ++i) #define foR(i,l,r) for (int i = l; i >= r; --i) #define db double const int N = 1e5 + 10; db mx[N << 2]; int siz[N << 2]; #define ls x << 1 #define rs x << 1 | 1
int Get (int x, int l, int r, db k) { if ( mx[x] <= k ) return 0; if (l == r) return (mx[x] > k); int mid = l + r >> 1; if ( mx[ls] <= k ) return Get (rs, mid + 1, r, k); return Get (ls, l, mid, k) + siz[x] - siz[ls]; }
void update (int x, int l, int r, int p, db y) { if (l == r) return (mx[x] = 1. * (y / p), siz[x] = 1), void(); int mid = l + r >> 1; if (p <= mid) update (ls, l, mid, p, y); else update (rs, mid + 1, r, p, y); siz[x] = siz[ls] + Get(rs, mid+ 1, r, mx[ls]); mx[x] = max(mx[ls], mx[rs]); }
int main() { int n, m; read(n); read(m); for (int i = 1, x, y; i <= m; ++i) { read(x), read(y); update(1, 1, n, x, y); printf ("%d\n", siz[1]); } return 0; }
|