# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
672215 | sudheerays123 | Trading (IZhO13_trading) | C++17 | 1 ms | 340 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;
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |