# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
896958 | borisAngelov | 거래 (IZhO13_trading) | C++17 | 119 ms | 23068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |