Submission #955818

#TimeUsernameProblemLanguageResultExecution timeMemory
955818vjudge1Pinball (JOI14_pinball)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ull; struct ured{ int a,b,c; ull d; }; int m,n; ull prosto(int L,int R,ull D,int i,ured arr[]){ if(i==-1){ if(L!=1||R!=n)return -1; else return D; } if(arr[i].c>=L&&arr[i].c<=R){ int h=prosto(L,R,D,i-1,arr); if(arr[i].a<L||arr[i].b>R){ int k=prosto(min(arr[i].a,L),max(arr[i].b,R),D+arr[i].d,i-1,arr); if(k!=-1&&h!=-1)h=min(h,k); else h=max(h,k); } return h; }else{ return prosto(L,R,D,i-1,arr); } } int main() { cin>>m>>n; ured arr[m]; for(int i=0;i<m;i++){ cin>>arr[i].a>>arr[i].b>>arr[i].c>>arr[i].d; } ull rez=LLONG_MAX; for(int i=m-1;i>=0;i--){ ull k=min(rez,prosto(arr[i].a,arr[i].b,arr[i].d,i-1,arr)); if(k!=-1)rez=min(rez,k); } if(rez==LLONG_MAX)cout<<-1; else cout<<rez; 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...