답안 #681948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681948 2023-01-14T23:28:35 Z speedyArda 거래 (IZhO13_trading) C++14
0 / 100
15 ms 28444 KB
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
const int MAXN = 600005;
vector<vector<pair<ll, pair<ll, ll>>>> beginr(MAXN), endr(MAXN);

int main()
{
    ll n, m;
    cin >> n >> m;
    multiset<pair<ll, pair<ll, ll>>> curr;
    for (int i = 1; i <= m; i++)
    {
        pair<ll, pair<ll, ll>> temp;
        ll f, s, t;
        cin >> f >> s >> t;
        temp.first = t;
        temp.second.first = f;
        temp.second.second = s;
        beginr[f].push_back(temp);
        endr[s + 1].push_back(temp);
    }
    for (int day = 1; day <= n; day++)
    {
        for (pair<ll, pair<ll, ll>> e : endr[day])
        {
            curr.erase(curr.find({-e.first, {e.second.first, e.second.second}}));
        }

        for (pair<ll, pair<ll, ll>> e : beginr[day])
        {
            curr.insert({-e.first, {e.second.first, e.second.second}});
        }
        pair<ll, pair<ll, ll>> maxi;
        if (curr.size() > 0)
            maxi = *(curr.begin());
        else
            maxi = {0, {day, day}};
        // if (day == 5)
        // cout << maxi.first << " " << maxi.second << "\n";
        ll elem = -1 * (maxi.first);
        cout << (elem) + day - maxi.second.first;
        if (day != n)
            cout << " ";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 28372 KB Output is correct
2 Incorrect 14 ms 28444 KB Output isn't correct
3 Halted 0 ms 0 KB -