#include<cstdio> #include<bitset> #include<algorithm> using namespace std; typedef long long ll; int n, h; ll r = -1; bitset<20> bs; struct st { int h, w, f; bool operator<(st i) const { return w + f<i.w + i.f; } }a[20]; int main() { scanf("%d %d", &n, &h); for (int i = 0; i<n; i++) scanf("%d %d %d", &a[i].h, &a[i].w, &a[i].f); sort(a, a + n); for (int i = 0; i<1 << n; i++) { bs = i; ll s = 0, p = 1e9, q = 0; for (int j = 0; j<n; j++) { if (bs[j]) continue; p = min(p, a[j].f - q); q += a[j].w; s += a[j].h; } if (s >= h) r = max(r, p); } if (r<0) puts("Mark is too tall"); else printf("%lld", r); return 0; }
10649번: 프리스비
https://www.acmicpc.net/problem/10649
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기