# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331238 | Sho10 | Trading (IZhO13_trading) | C++14 | 59 ms | 57964 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> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int n,m;
struct trader{
int left,right,price;
};
trader a[300005];
set<int>intrare[300005],iesire[300005];
int32_t main(){
CODE_START
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>a[i].left>>a[i].right>>a[i].price;
intrare[a[i].left].insert(a[i].price-a[i].left);
iesire[a[i].right+1].insert(a[i].price-a[i].left);
}
multiset<int>s;
for(int i=1;i<=n;i++)
{
for(auto it : intrare[i]){
s.insert(it);
}
for(auto it : iesire[i]){
s.erase(s.find(it));
}
if(s.size()==0){
cout<<0<<' ';
}else {
auto it=s.end();
it--;
cout<<i+*(it)<<' ';
}
}
}
/*
5 2
1 3 2
2 4 6
6 4
4 4 3
1 2 5
5 6 1
6 6 1
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |