Submission #874413

#TimeUsernameProblemLanguageResultExecution timeMemory
874413Darren0724Treatment Project (JOI20_treatment)C++17
0 / 100
3044 ms7504 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false);cin.tie(0); #define int long long #define all(x) x.begin(), x.end() #define x first #define y second const int N=150005; const int INF=1e18; struct st{ int t,l,r,c; bool operator<(st &o){ return this->l<o.l; } }; int32_t main() { int m,n;cin>>m>>n; vector<st> v(n); for(int i=0;i<n;i++){ int a,b,c,d;cin>>a>>b>>c>>d; v[i]={a,b,c,d}; } sort(all(v)); vector<int> dp(n); for(int i=0;i<n;i++){ auto [t,l,r,c]=v[i]; int ans=(l==1?c:INF); for(int j=0;j<i;j++){ auto [t1,l1,r1,c1]=v[j]; if(abs(t-t1)<=r1-l+1){ ans=min(ans,dp[j]+c); } } dp[i]=ans; } int ans=INF; for(int i=0;i<n;i++){ if(v[i].r==m){ ans=min(ans,dp[i]); } } cout<<(ans==INF?-1:ans)<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...