Submission #1107218

# Submission time Handle Problem Language Result Execution time Memory
1107218 2024-11-01T03:00:14 Z 12345678 Inspections (NOI23_inspections) C++17
22 / 100
114 ms 20912 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct interval
{
    ll l, r, x;
    interval(ll l, ll r, ll x): l(l), r(r), x(x) {}
    bool operator<(const interval &o) const {return l<o.l;}
};

const int nx=2e5+5;

ll n, m, q, l, r, t, sf[nx], res[nx], cur, sm, idx;
set<interval> s;
vector<pair<ll, ll>> v, qrs;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m>>q;
    s.insert(interval(1, n, -1e18));
    for (int i=1; i<=m; i++)
    {
        cin>>l>>r;
        auto itr=prev(s.upper_bound(interval(l, 0, 0)));
        auto tmp=interval(*itr);
        s.erase(itr);
        if (itr->r>=r)
        {
            v.push_back({t-tmp.x+l-tmp.l, r-l+1});
            if (tmp.l<l) s.insert(interval(tmp.l, l-1, tmp.x));
            s.insert(interval(l, r, t));
            if (r<tmp.r) s.insert(interval(r+1, tmp.r, tmp.x+r+1-tmp.l));
            t+=r-l+1;
            //cout<<"after "<<i<<'\n';
            //for (auto x:s) cout<<x.l<<' '<<x.r<<' '<<x.x<<'\n';
            continue;
        }
        else
        {
            v.push_back({t-(tmp.x+l-tmp.l), tmp.r-l+1});
            if (tmp.l<l) s.insert(interval(tmp.l, l-1, tmp.x));
        }
        itr=s.lower_bound(interval(l, 0, 0));
        while (itr!=s.end()&&itr->l<=r)
        {
            if (itr->r<=r)
            {
                v.push_back({t+itr->l-l-itr->x, itr->r-itr->l+1});
                itr=s.erase(itr);
            }
            else
            {
                v.push_back({t+itr->l-l-itr->x, r-itr->l+1});
                if (r<itr->r) s.insert(interval(r+1, itr->r, itr->x+r-itr->l+1));
                s.erase(itr);
                break;
            }
        }
        s.insert(interval(l, r, t));
        t+=r-l+1;
        //cout<<"after "<<i<<'\n';
        //for (auto x:s) cout<<x.l<<' '<<x.r<<' '<<x.x<<'\n';
    }
    //for (auto x:v) cout<<x.first<<' '<<x.second<<'\n';
    sort(v.begin(), v.end());
    for (auto x:v) if (x.first<1e18) sm+=x.second;
    for (int i=1; i<=q; i++) cin>>sf[i], qrs.push_back({sf[i], i});
    sort(qrs.begin(), qrs.end());
    for (int i=0; i<q; i++)
    {
        while (idx<v.size()&&v[idx].first<=qrs[i].first) sm-=v[idx].second, idx++;
        res[qrs[i].second]=sm;
    }
    for (int i=1; i<=q; i++) cout<<res[i]<<' ';
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:75:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         while (idx<v.size()&&v[idx].first<=qrs[i].first) sm-=v[idx].second, idx++;
      |                ~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2552 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2552 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 43 ms 9192 KB Output is correct
4 Correct 44 ms 9152 KB Output is correct
5 Correct 106 ms 20912 KB Output is correct
6 Correct 114 ms 19296 KB Output is correct
7 Correct 91 ms 15032 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2552 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2552 KB Output is correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Halted 0 ms 0 KB -