제출 #937017

#제출 시각아이디문제언어결과실행 시간메모리
937017qwe1rt1yuiop1Inspections (NOI23_inspections)C++14
55 / 100
2064 ms994572 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;
using pii = pair<int, int>;

void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<pii> v(m);
    vector<int> tmp(1, 0);
    for (auto &[a, b] : v)
    {
        cin >> a >> b;
        --a;
        tmp.emplace_back(a), tmp.emplace_back(b);
    }
    sort(tmp.begin(), tmp.end());
    tmp.resize(unique(tmp.begin(), tmp.end()) - tmp.begin());
    for (auto &[a, b] : v)
    {
        a = lower_bound(tmp.begin(), tmp.end(), a) - tmp.begin();
        b = lower_bound(tmp.begin(), tmp.end(), b) - tmp.begin();
    }

    vector<int> lst((int)tmp.size(), -1), day(1, 0);
    multiset<pii> st;
    for (int i = 0; i < m; ++i)
    {
        auto [a, b] = v[i];
        for (int j = a + 1; j <= b; ++j)
        {
            if (lst[j] != -1)
                st.emplace((day[i] - tmp[a]) - (day[lst[j]] - tmp[v[lst[j]].first]), (j == -1 ? 1 : (tmp[j] - tmp[j - 1])));
            lst[j] = i;
        }
        day.emplace_back(day.back() + (tmp[b] - tmp[a]));
    }

    // for (auto [a, b] : st)
    //     cout << a << ' ' << b << '\n';

    vector<pii> qry(q);
    for (int i = 0; i < q; ++i)
        cin >> qry[i].first, qry[i].second = i;
    sort(qry.begin(), qry.end());
    // reverse(qry.begin(), qry.end());
    vector<int> ans(q);
    int sum = 0;
    for (pii i : st)
        sum += i.second;
    for (auto [val, id] : qry)
    {
        while (!st.empty() && st.begin()->first <= val)
            sum -= st.begin()->second, st.erase(st.begin());
        ans[id] = sum;
    }
    for (int i : ans)
        cout << i << ' ';
    cout << '\n';
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:12:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   12 |     for (auto &[a, b] : v)
      |                ^
Main.cpp:20:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |     for (auto &[a, b] : v)
      |                ^
Main.cpp:30:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   30 |         auto [a, b] = v[i];
      |              ^
Main.cpp:52:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |     for (auto [val, id] : qry)
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...