1 条题解

  • -1
    @ 2022-10-18 21:10:45
    备注:
    ******************************************/
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    #include <map>
    using namespace std;
    #define LL long long
    const int N = 1e6 + 10;
    const int INF = 0x3f3f3f3f;
    int sum[N];
    int a[N], p[N];
    int n, m;
    inline int lowbit(int x)
    {
    	return x & -x;
    }
    inline void add(int x, int y)
    {
    	while(x <= n)
    	{
    		sum[x] += y;
    		x += lowbit(x);
    	}
    }
    inline int find(int x)
    {
    	int ans = 0;
    	while(x)
    	{
    		ans += sum[x];
    		x -= lowbit(x);
    	}
    	return ans;
    }
    signed main()
    {
    	//freopen(".in", "w", stdin);
    	//freopen(".out", "r", stdout);
    	int m;
    	cin>>m;
    	for(int i = 0; i < m; i++)
    	{
    		cin>>p[i];
    		p[i]++;
    		n = max(n, p[i]);
    		int y;
    		cin>>y;
    	}
    	for(int i = 0; i < m; i++)
    	{
    		add(p[i], 1);
    		a[find(p[i])]++;
    	}
    	for(int i = 1; i <= m; i++)
    	{
    		cout<<a[i]<<endl;
    	}
    	return 0;
    }
    
    
    • 1

    信息

    ID
    445
    时间
    250ms
    内存
    64MiB
    难度
    7
    标签
    递交数
    21
    已通过
    8
    上传者