# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867466 | Vladth11 | Trading (IZhO13_trading) | C++14 | 258 ms | 31172 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.
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const ll NMAX = 300002;
const ll INF = (1LL << 60);
const ll nrbits = 20;
const ll MOD = 998244353;
const ll bucket = 320;
const double eps = 0.00000001;
struct ura{
int l, r, x, bgt;
}qq[NMAX];
multiset <int> st;
vector <int> events[NMAX];
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m, i;
cin >> n >> m;
for(i = 1; i <= m; i++){
int a, b, c;
cin >> a >> b >> c;
qq[i] = {a, b, c};
events[a].push_back(i);
events[b + 1].push_back(-i);
}
int offset = 0;
for(i = 1; i <= n; i++){
offset++;
for(auto x : events[i]){
if(x < 0){
st.erase(st.find(qq[-x].bgt));
}else{
st.insert(qq[x].x - offset);
qq[x].bgt = qq[x].x - offset;
}
}
if(st.size() == 0){
cout << 0 << " ";
continue;
}
auto it = prev(st.end());
cout << (*it) + offset << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |