Submission #672215

#TimeUsernameProblemLanguageResultExecution timeMemory
672215sudheerays123Trading (IZhO13_trading)C++17
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long int const ll N = 100+5 , INF = 1e18 , MOD = 1e9+7; void solve(){ ll n,m; cin >> n >> m; vector<tuple<ll,ll,ll>> b; for(ll i = 1; i <= m; i++){ ll l,r,x; cin >> l >> r >> x; b.push_back(make_tuple(x,l,r)); } sort(b.rbegin(),b.rend()); vector<ll> a(n+5,0); for(auto u : b){ ll x,l,r; tie(x,l,r) = u; ll low = l , high = r; ll ans = 0; while(low <= high){ ll mid = (low+high)/2; if(a[mid] < (x+mid-l)){ ans = mid; low = mid+1; } else high = mid-1; } for(ll i = l; i <= ans; i++){ a[i] = max(a[i],x); x++; } } for(ll i = 1; i <= n; i++) cout << a[i] << " "; } int main(){ fast; ll tc = 1; // cin >> tc; while(tc--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...