# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896405 | Aiperiii | Pinball (JOI14_pinball) | C++14 | 1054 ms | 47392 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>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);
int n,m;
cin>>m>>n;
vector <int> a(m),b(m),c(m),d(m);
for(int i=0;i<m;i++){
cin>>a[i]>>b[i]>>c[i]>>d[i];
}
int mn=1e18;
for(int i=0;i<(1<<m);i++){
vector <int> v;
int sum=0;
for(int j=0;j<m;j++){
if((i & (1<<j))!=0){
v.pb(j);
sum+=d[j];
}
}
set <int> st;
for(int j=1;j<=n;j++){
int cur=j;
int s=0;
while(true){
bool flag=false;
for(int t=s;t<v.size();t++){
int k=v[t];
if(a[k]<=cur && cur<=b[k]){
cur=c[k];
flag=true;
s=t+1;
break;
}
}
if(!flag){
st.insert(cur);break;
}
}
if(v.size()==m)cout<<"\n";
}
if(st.size()==1)mn=min(mn,sum);
}
if(mn==1e18)cout<<-1<<"\n";
else cout<<mn<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |