# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
18078 | | comet | 매트 (KOI15_mat) | C++98 | | 10 ms | 1212 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 <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
int N,W;
struct mat{
int p,l,r,h,k;
}a[100];
bool cross(int x,int y){
if(a[x].r<=a[y].l)return 0;
if(a[x].l>=a[y].r)return 0;
if(a[x].p==a[y].p)return 1;
if(a[x].h+a[y].h<=W)return 0;
return 1;
}
int main(){
scanf("%d%d",&N,&W);
int p,l,r,h,k;
for(int i=0;i<N;i++){
scanf("%d%d%d%d%d",&p,&l,&r,&h,&k);
a[i]=mat{p,l,r,h,k};
}
int ans=0;
for(int i=(1<<N)-1;i>0;i--){
vector<int> s;
int sum=0;
for(int j=0;j<N;j++){
if(i>>j&1){
s.push_back(j);
sum+=a[j].k;
}
}
bool ok=true;
for(int j=0;j<s.size();j++){
for(int k=j+1;k<s.size();k++){
if(cross(s[j],s[k])){
ok=false;
goto apple;
}
}
}
ans=max(ans,sum);
apple:;
}
printf("%d\n",ans);
return 0;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |