Submission #893323

# Submission time Handle Problem Language Result Execution time Memory
893323 2023-12-27T01:57:06 Z fdnfksd Inspections (NOI23_inspections) C++14
55 / 100
148 ms 23888 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxn=3e5+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll s[maxn];
pli t[maxn];
ll q;
ll pre[maxn];
void update(ll x,ll v)
{
    //x++;
    ll cc=upper_bound(s+1,s+q+1,x)-s-1;
    pre[cc]+=v;
}
ll giao(ll i,ll j,ll l,ll r)
{
    return max(0ll,min(j,r)-max(i,l)+1);
}
ll n,m,x[maxn],y[maxn],r[maxn],tg[maxn],pos[maxn];

void solve()
{
    cin >> n >> m >> q;
    for(int i=1;i<=m;i++)
    {
        cin >> x[i] >> y[i];
    }
    for(int i=1;i<=q;i++)
    {
        cin >> s[i];
        t[i]={s[i],i};
    }
    sort(s+1,s+q+1);
    sort(t+1,t+q+1);
    set<int>s;
    ll sum=0;
    for(int i=1;i<=m;i++)
    {
        auto it=s.lower_bound(x[i]);
        vector<ll>xoa;
        if(i>0) sum+=y[i-1]-x[i-1]+1;
        if(it!=s.begin())
        {
            it--;
            ll l=*it;
            if(r[l]>=x[i])
            {
                 ll cc=sum - (tg[l]+x[i]-l) -1;
                 update(cc,giao(x[i],y[i],l,r[l]));
                 ll luu=r[l];
                 r[l]=x[i]-1;
                 if(luu>y[i])
                 {
                    s.insert(y[i]+1);
                    s.insert(x[i]);
                    r[x[i]]=y[i];
                    tg[x[i]]=sum;
                    r[y[i]+1]=luu;
                    tg[y[i]+1]=tg[l]+(y[i]+1-l);
                    continue;
                 }
            }
            it++;
        }
        while(it!=s.end()&&(*it)<=y[i])
        {
            ll l=*it;
            ll cc=sum+l-x[i]-tg[l]-1;
            update(cc,giao(l,r[l],x[i],y[i]));
            xoa.pb(l);
            if(r[l]>y[i])
            {
                s.insert(y[i]+1);
                r[y[i]+1]=r[l];
                tg[y[i]+1]=tg[l]+(y[i]+1-l);
                break;
            }
            it++;
        }
        r[x[i]]=y[i];
        tg[x[i]]=sum;
        for(auto zz:xoa) s.erase(zz);
        s.insert(x[i]);
    }
    for(int i=q;i>=1;i--)
    {
        pre[i]+=pre[i+1];
        pos[t[i].se]=i;
    }
    for(int i=1;i<=q;i++)
    {
        cout << pre[pos[i]]<<' ';
    }
}
int main()
{
    fastio
    //freopen("c.INP","r",stdin);
    //freopen("c.OUT","w",stdout);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14680 KB Output is correct
2 Correct 2 ms 14684 KB Output is correct
3 Correct 2 ms 14684 KB Output is correct
4 Correct 2 ms 14684 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 2 ms 14680 KB Output is correct
7 Correct 2 ms 14684 KB Output is correct
8 Correct 2 ms 14684 KB Output is correct
9 Correct 2 ms 14684 KB Output is correct
10 Correct 2 ms 14684 KB Output is correct
11 Correct 2 ms 14804 KB Output is correct
12 Correct 2 ms 14684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14680 KB Output is correct
2 Correct 2 ms 14684 KB Output is correct
3 Correct 2 ms 14684 KB Output is correct
4 Correct 2 ms 14684 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 2 ms 14680 KB Output is correct
7 Correct 2 ms 14684 KB Output is correct
8 Correct 2 ms 14684 KB Output is correct
9 Correct 2 ms 14684 KB Output is correct
10 Correct 2 ms 14684 KB Output is correct
11 Correct 2 ms 14804 KB Output is correct
12 Correct 2 ms 14684 KB Output is correct
13 Correct 55 ms 20816 KB Output is correct
14 Correct 51 ms 20692 KB Output is correct
15 Correct 53 ms 20820 KB Output is correct
16 Correct 54 ms 21076 KB Output is correct
17 Correct 53 ms 20864 KB Output is correct
18 Correct 54 ms 20820 KB Output is correct
19 Correct 56 ms 21072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14680 KB Output is correct
2 Correct 2 ms 14684 KB Output is correct
3 Correct 54 ms 20948 KB Output is correct
4 Correct 57 ms 21588 KB Output is correct
5 Correct 148 ms 23888 KB Output is correct
6 Incorrect 118 ms 23632 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14680 KB Output is correct
2 Correct 2 ms 14684 KB Output is correct
3 Correct 2 ms 14684 KB Output is correct
4 Correct 2 ms 14684 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 2 ms 14680 KB Output is correct
7 Correct 2 ms 14684 KB Output is correct
8 Correct 2 ms 14684 KB Output is correct
9 Correct 2 ms 14684 KB Output is correct
10 Correct 2 ms 14684 KB Output is correct
11 Correct 2 ms 14804 KB Output is correct
12 Correct 2 ms 14684 KB Output is correct
13 Correct 55 ms 20816 KB Output is correct
14 Correct 51 ms 20692 KB Output is correct
15 Correct 53 ms 20820 KB Output is correct
16 Correct 54 ms 21076 KB Output is correct
17 Correct 53 ms 20864 KB Output is correct
18 Correct 54 ms 20820 KB Output is correct
19 Correct 56 ms 21072 KB Output is correct
20 Correct 57 ms 22064 KB Output is correct
21 Correct 54 ms 21264 KB Output is correct
22 Correct 55 ms 22216 KB Output is correct
23 Correct 52 ms 21316 KB Output is correct
24 Correct 53 ms 20816 KB Output is correct
25 Correct 59 ms 21528 KB Output is correct
26 Correct 56 ms 22100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14680 KB Output is correct
2 Correct 2 ms 14684 KB Output is correct
3 Correct 2 ms 14684 KB Output is correct
4 Correct 2 ms 14684 KB Output is correct
5 Correct 2 ms 14684 KB Output is correct
6 Correct 2 ms 14680 KB Output is correct
7 Correct 2 ms 14684 KB Output is correct
8 Correct 2 ms 14684 KB Output is correct
9 Correct 2 ms 14684 KB Output is correct
10 Correct 2 ms 14684 KB Output is correct
11 Correct 2 ms 14804 KB Output is correct
12 Correct 2 ms 14684 KB Output is correct
13 Correct 55 ms 20816 KB Output is correct
14 Correct 51 ms 20692 KB Output is correct
15 Correct 53 ms 20820 KB Output is correct
16 Correct 54 ms 21076 KB Output is correct
17 Correct 53 ms 20864 KB Output is correct
18 Correct 54 ms 20820 KB Output is correct
19 Correct 56 ms 21072 KB Output is correct
20 Correct 2 ms 14680 KB Output is correct
21 Correct 2 ms 14684 KB Output is correct
22 Correct 54 ms 20948 KB Output is correct
23 Correct 57 ms 21588 KB Output is correct
24 Correct 148 ms 23888 KB Output is correct
25 Incorrect 118 ms 23632 KB Output isn't correct
26 Halted 0 ms 0 KB -