# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
755605 | Nika533 | Trading (IZhO13_trading) | C++17 | 336 ms | 35136 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.
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
using namespace std;
int n,m,T,k;
string s;
void test_case() {
cin>>n>>m;
pair<int,int> arr[m+1];
vector<int> l[n+1];
vector<int> r[n+1];
for (int i=1; i<=m; i++) {
cin>>arr[i].f>>arr[i].s;
int x;
cin>>x;
l[arr[i].f].pb(x-arr[i].f+1);
r[arr[i].s].pb(x-arr[i].f+1);
}
int ans=0;
multiset<int> myset;
for (int i=1; i<=n; i++) {
for (int j=0; j<l[i].size(); j++) {
myset.insert(l[i][j]);
}
if (myset.size()==0) {
cout<<0<<" ";
continue;
}
set<int> :: iterator it = myset.end();
it--;
cout<<(*it)+i-1<<" ";
for (int j=0; j<r[i].size(); j++) {
myset.erase(myset.find(r[i][j]));
}
}
cout<<endl;
}
main () {
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
T=1;
while (T--) {
test_case();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |