# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053023 | Piokemon | Trading (IZhO13_trading) | C++17 | 155 ms | 29628 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>
using namespace std;
typedef long long int ll;
constexpr int N = 3e5;
vector<pair<int,int>> wyd[N+9];
int odp[N+9];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,l,r,c;
cin >> n >> m;
for (int x=1;x<=m;x++){
cin >> l >> r >> c;
c-=l;
wyd[l].push_back({c,x});
wyd[r+1].push_back({c,-x});
}
set<pair<int,int>> ter; ter.insert({-2e9,-1});
for (int x=1;x<=n;x++){
for (pair<int,int> y:wyd[x]){
if (y.second>0)ter.insert(y);
else ter.erase({y.first,-y.second});
}
odp[x]=(*ter.rbegin()).first+x;
}
for (int x=1;x<=n;x++) cout << max(odp[x],0) << ' ';
cout << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |