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 endl '\n'
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define f first
#define s second
#define fore(i,l,r) for(int i = l; i < r;i++)
#define fo(i,n) fore(i,0,n)
#define ll long long
#define ii pair<int,int>
using namespace std;
using vi = vector<int>;
struct cosa{
int a,b,c,d;
};
vector<cosa> arr;
int main() {
int m,n;
cin >> m >> n;
ll ans = 1e18;
fo(i,m){
cosa a;
cin >> a.a >> a.b >> a.c >> a.d;
arr.pb(a);
}
for(int bit = 1; bit <= (1<<m)-1; bit++){
vector<int> act(n+23,0);ll cost = 0;
fore(i,1,n+1)act[i]=i;
for(int j = 0 ; j < m; j++){
if(bit&(1<<j)){
cosa a = arr[j];cost+=a.d;
for(int i = 1; i <= n;i++){
if(act[i] <= a.b and a.a <= act[i]){
act[i]=a.c;
}
}
}
}
// for(int i = 1; i <=n;i++)cout<<act[i]<<" ";
// cout<<endl;
bool f = true;
for(int i = 1;i <= n;i++)if(act[i]!=act[1])f=false;
if(f){
ans = min(ans, cost);
}
}
cout << ans;
}
# | 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... |