# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
245172 | 2020-07-05T16:26:19 Z | urd05 | 매트 (KOI15_mat) | C++14 | 33 ms | 512 KB |
#include <bits/stdc++.h> using namespace std; struct Mat { int p,l,r,h,k; }; Mat arr[3000]; bool meet[10][10]; int n,w; bool isMeet(Mat a,Mat b) { if (a.p==b.p) { if (a.r<=b.l||b.r<=a.l) { return false; } return true; } else { if (a.h+b.h<=w) { return false; } if (a.r<=b.l||b.r<=a.l) { return false; } return true; } } long long dp[3000]; //dp[i]:start with i long long ans(int v) { if (dp[v]!=-1) { return dp[v]; } long long ret=arr[v].k; for(int i=0;i<n;i++) { if (i!=v&&arr[i].l>=arr[v].r) { ret=max(ret,arr[v].k+ans(i)); } } dp[v]=ret; return ret; } int main(void) { scanf("%d %d",&n,&w); for(int i=0;i<n;i++) { scanf("%d %d %d %d %d",&arr[i].p,&arr[i].l,&arr[i].r,&arr[i].h,&arr[i].k); } if (n<=10) { long long ret=0; for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if (isMeet(arr[i],arr[j])) { meet[i][j]=true; } } } for(int i=0;i<(1<<n);i++) { bool flag=true; for(int one=0;one<n;one++) { for(int two=0;two<n;two++) { if (one!=two&&(i&(1<<one))!=0&&(i&(1<<two))!=0) { if (meet[one][two]) { flag=false; break; } } } } if (!flag) { continue; } long long sum=0; for(int j=0;j<n;j++) { if ((i&(1<<j))!=0) { sum+=arr[j].k; } } ret=max(ret,sum); } printf("%lld",ret); } memset(dp,-1,sizeof(dp)); long long ret=0; for(int i=0;i<n;i++) { ret=max(ret,ans(i)); } printf("%lld",ret); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 384 KB | Output is correct |
2 | Correct | 33 ms | 512 KB | Output is correct |
3 | Correct | 33 ms | 384 KB | Output is correct |
4 | Correct | 31 ms | 512 KB | Output is correct |
5 | Correct | 31 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 384 KB | Output is correct |
2 | Incorrect | 32 ms | 512 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |