# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170822 | davitmarg | Trading (IZhO13_trading) | C++17 | 563 ms | 45936 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 300005;
int n, m;
vector<int> add[N], rem[N];
multiset<int> s;
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
add[i].PB(-i);
rem[i].PB(-i);
}
while (m--)
{
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
add[l].PB(x - l);
rem[r].PB(x - l);
}
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < add[i].size(); j++)
s.insert(add[i][j]);
printf("%d ", i + (*s.rbegin()));
for (int j = 0; j < rem[i].size(); j++)
s.erase(s.find(rem[i][j]));
}
cout << endl;
return 0;
}
/*
2
2 0
3
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |