Submission #896958

#TimeUsernameProblemLanguageResultExecution timeMemory
896958borisAngelovTrading (IZhO13_trading)C++17
100 / 100
119 ms23068 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 300005;

int n, q;

vector<pair<int, int>> byL[maxn];
int answer[maxn];

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> q;

    for (int i = 1; i <= q; ++i)
    {
        int l, r, val;
        cin >> l >> r >> val;
        byL[l].push_back(make_pair(r, val - l));
    }

    priority_queue<pair<int, int>> pq;

    for (int i = 1; i <= n; ++i)
    {
        while (!pq.empty() && pq.top().second < i)
        {
            pq.pop();
        }

        for (int j = 0; j < byL[i].size(); ++j)
        {
            pq.push(make_pair(byL[i][j].second, byL[i][j].first));
        }

        if (!pq.empty())
        {
            answer[i] = pq.top().first + i;
        }
        else
        {
            answer[i] = 0;
        }
    }

    for (int i = 1; i <= n; ++i)
    {
        cout << answer[i] << ' ';
    }

    cout << endl;

    return 0;
}

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int j = 0; j < byL[i].size(); ++j)
      |                         ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...