답안 #937001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937001 2024-03-03T08:13:08 Z qwe1rt1yuiop1 Inspections (NOI23_inspections) C++14
0 / 100
2000 ms 1026772 KB
#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;
        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; j <= b; ++j)
        {
            if (lst[j] != -1)
                st.emplace((day[i] - a) - (day[lst[j]] - v[lst[j]].first), tmp[j] - tmp[j - 1]);
            lst[j] = i;
        }
        day.emplace_back(day.back() + (tmp[b] - tmp[a] + 1));
    }

    // 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;
}

Compilation message

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:19:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |     for (auto &[a, b] : v)
      |                ^
Main.cpp:29:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |         auto [a, b] = v[i];
      |              ^
Main.cpp:51:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   51 |     for (auto [val, id] : qry)
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 1176 KB Output is correct
3 Correct 274 ms 88232 KB Output is correct
4 Correct 485 ms 132428 KB Output is correct
5 Execution timed out 2078 ms 1026772 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -