比赛 2024暑假C班集训B 评测结果 AAAAAATTTTTTTTTTTTTT
题目名称 天天爱射击 最终得分 30
用户昵称 liuyiche 运行时间 56.043 s
代码语言 C++ 内存使用 5.34 MiB
提交时间 2024-07-11 11:28:42
显示代码纯文本
/*#include <bits/stdc++.h>
            
using namespace std;

typedef long long ll;

int n, m;
struct node
{
    int l;
    int r;
    int s;
};
vector<node> q(200005);

struct node2
{
    int id;
    int val;
};
vector<node2> z(200005);
int blog[200005];
int L[505];
int R[505];
int cntq[505];
int cnt[200005];

inline bool cmp1(node2 a, node2 b)
{
    return a.val < b.val;
}

inline void build()
{
    int block = sqrt(m);
    int num = m/block;
    if(m%block) num++;
    for(ll i = 1; i <= num; ++i)
    {
        L[i] = (i-1)*block+1;
        R[i] = i*block;
    }
    R[num] = m;
    for(ll i = 1; i <= m; ++i)
        blog[i] = (i-1)/block+1;
    sort(z.begin()+1,z.begin()+m+1,cmp1);
}

inline void add(int l, int r, int num)
{
    if(blog[l] == blog[r])
    {
        for(int i = l; i <= r; ++i)
        {
            num--;
            if(num == 0)
            {
                cnt[i]++;
                break;
            }
        }
    }
    else
    {
        for(int i = l; i <= R[blog[l]]; ++i)
        {
            num--;
            if(num == 0)
            {
                cnt[i]++;
                break;
            }
        }
        for(int i = blog[l]+1; i < blog[r]; ++i)
        {
            if(num-(R[i]-L[i]+1) > 0)
                num -= (R[i]-L[i]+1);
            else
            {
                for(int j = L[i]; j <= R[i]; ++j)
                {
                    num--;
                    if(num == 0)
                    {
                        cnt[j]++;
                        break;
                    }
                }
                break;
            }
        }
        for(int i = L[blog[r]]; i <= r; ++i)
        {
            num--;
            if(num == 0)
            {
                cnt[i]++;
                break;
            }
        }
    }
    //cout << cnt[l] << " " << cnt[r] << '\n';
}

inline bool cmp2(node2 a, node2 b)
{
    return a.id < b.id;
}
    
int main()
{
    //freopen("shooting10.in", "r", stdin);
    //freopen("shooting.out", "w", stdout);
        
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
            
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        cin >> q[i].l >> q[i].r >> q[i].s;
    for(int i = 1; i <= m; ++i)
        cin >> z[i].val, z[i].id = i;
    build();
    
    for(int i = 1; i <= n; ++i)
    {
        node2 tmp1, tmp2;
        tmp1.val = q[i].l;
        tmp2.val = q[i].r;
        int l = lower_bound(z.begin()+1,z.begin()+m+1,tmp1,cmp1)-z.begin();
        int r = lower_bound(z.begin()+1,z.begin()+m+1,tmp2,cmp1)-z.begin();
        if(l == m+1)
            l = m;
        if(r == m+1)
            r = m;
        if(z[r].val > q[i].r)
            r--;
        //cout << l << " " << r << '\n';
        add(l,r,q[i].s);
    }
    for(int i = 1; i <= m; ++i)
        z[i].val = cnt[i]+cntq[blog[i]];
    sort(z.begin()+1,z.begin()+m+1,cmp2);
    for(int i = 1; i <= m; ++i)
        cout << z[i].val << '\n';
    
   	return 0;
}*/

#include <bits/stdc++.h>
            
using namespace std;

typedef long long ll;

int n, m;
struct node
{
    int l, r, s;
};
vector<node> q(200005);
    
int main()
{
    freopen("shooting.in", "r", stdin);
    freopen("shooting.out", "w", stdout);
        
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
            
    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        cin >> q[i].l >> q[i].r >> q[i].s;
    for(int i = 1; i <= m; ++i)
    {
        int a;
        cin >> a;
        int ans = 0;
        for(int j = 1; j <= n; ++j)
        {
            if(q[j].s > 0 && a >= q[j].l && a <= q[j].r)
            {
                q[j].s--;
                if(q[j].s == 0)
                    ans++;
            }
        }
        cout << ans << '\n';
    }
    
   	return 0;
}