Submission #331238

#TimeUsernameProblemLanguageResultExecution timeMemory
331238Sho10Trading (IZhO13_trading)C++14
0 / 100
59 ms57964 KiB
#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 timeMemoryGrader output
Fetching results...