Tag: problem: (C) Hacker

Codeforces Round #422 (Div. 2), problem: (C) Hacker, pack your bags Solution In C/C++

#include<cstdio> #include<vector> #include<cstring> #include<algorithm> #define ll long long using namespace std; ll ans,c,n,x,L,R,cc; vector<pair<ll,ll> >l,r; int main(){ scanf(“%lld%lld”,&n,&x); for(int i=1;i<=n;i++){ scanf(“%lld%lld%lld”,&L,&R,&cc); l.push_back(make_pair(R-L+1,cc)); r.push_back(make_pair(R-L+1,cc)); } memset(c,0x3f3f,sizeof(c));ans=c; for(int i=1;i<200100;i++){ for(int j=0;j<l.size();j++)l.first>=x?0:ans=min(ans,c.first]+l.second); for(int j=0;j<r.size();j++)c.first]=min(c.first],r.second); } printf(“%lld”,ans==c?-1:ans); return 0; }

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!