甚至都不是树形背包= =

把每条线抠出来,这一条线就是个链的依赖关系,随便背包一下

// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il int gi(){
int x=0,f=1;
char ch=getchar();
while(!isdigit(ch)){
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
return x*f;
}
struct yyb{int x,y,t,v;}s[210];
il bool operator <(const yyb&a,const yyb&b){return a.y<b.y;}
std::map<std::pair<int,int>,int>M;
int cnt;
std::vector<yyb>S[210];
int f[40010];
int main(){
#ifndef ONLINE_JUDGE
freopen("3961.in","r",stdin);
freopen("3961.out","w",stdout);
#endif
int n=gi(),t=gi();
for(int i=1;i<=n;++i){
s[i].x=gi(),s[i].y=gi(),s[i].t=gi(),s[i].v=gi();
int g=std::__gcd(s[i].x,s[i].y);
std::pair<int,int>pr=std::make_pair(s[i].x/g,s[i].y/g);
if(M.find(pr)==M.end())M[pr]=++cnt;
S[M[pr]].push_back(s[i]);
}
for(int i=1;i<=cnt;++i){
std::sort(S[i].begin(),S[i].end());
for(int p=t;p;--p){
int sumt=0,sumv=0;
for(int j=0;j<S[i].size();++j){
sumt+=S[i][j].t,sumv+=S[i][j].v;
if(sumt>p)break;
f[p]=std::max(f[p],f[p-sumt]+sumv);
}
}
}
printf("%d\n",f[t]);
return 0;
}

洛咕 P3961 [TJOI2013]黄金矿工的更多相关文章

  1. 洛谷3961 [TJOI2013]黄金矿工

    题目描述 小A最近迷上了在上课时玩<黄金矿工>这款游戏.为了避免被老师发现,他必须小心翼翼,因此他总是输.在输掉自己所有的金币后,他向你求助.每个黄金可以看做一个点(没有体积).现在给出你 ...

  2. 洛咕 P4304 [TJOI2013]攻击装置

    把坐标按照(x+y)%2染色可以发现这是个二分图 二分图最大独立集=点数-最大匹配 于是就是个算匹配的傻逼题了 // luogu-judger-enable-o2 #include<bits/s ...

  3. 洛咕 P3964 [TJOI2013]松鼠聚会

    有个结论就是把坐标\((x,y)\)变形成\(((x+y)/2,(x-y)/2)\),切比雪夫距离就变成了曼哈顿距离. 所以变换一下坐标直接统计答案即可. // luogu-judger-enable ...

  4. 洛咕 P3965 [TJOI2013]循环格

    同tjoi2010 打扫房间,每个点入度,出度都为1,可以向相邻4个点连边,但只有原来存在的边费用为0. // luogu-judger-enable-o2 #include<bits/stdc ...

  5. 洛咕3312 [SDOI2014]数表

    洛咕3312 [SDOI2014]数表 终于独立写出一道题了...真tm开心(还是先写完题解在写的) 先无视a的限制,设\(f[i]\)表示i的约数之和 不妨设\(n<m\) \(Ans=\su ...

  6. 洛咕 P3700 [CQOI2017]小Q的表格

    洛咕 P3700 [CQOI2017]小Q的表格 神仙题orz 首先推一下给的两个式子中的第二个 \(b\cdot F(a,a+b)=(a+b)\cdot F(a,b)\) 先简单的想,\(F(a,a ...

  7. 洛咕 P2336 [SCOI2012]喵星球上的点名

    洛咕 P2336 [SCOI2012]喵星球上的点名 先求出SA和height,一个点名串对应的就是一段区间,还有很多个点,就转化成了 有很多个区间,很多个点集,对每个区间计算和多少个点集有交,对每个 ...

  8. 洛咕 P4131 [WC2005]友好的生物

    洛咕 P4131 [WC2005]友好的生物 首先可以发现\(C\)是没有用的,可以乘进所有的权值里面做 考虑没有最后一维的限制,那么两个生物的友好值就是 \(\sum_{i=1}^k|a_i-b_i ...

  9. 洛咕 P4528 [CTSC2008]图腾

    洛咕 P4528 [CTSC2008]图腾 神题orz. 先约定abcd表示\(1\leq A<B<C<D\leq n\),而且\(y_a,y_b,y_c,y_d\)的排名正好是\( ...

随机推荐

  1. [翻译] RDVTabBarController

    RDVTabBarController https://github.com/robbdimitrov/RDVTabBarController 效果: Supports iPad and iPhone ...

  2. python 使用exchange发送邮件(三)

    FYI: https://blog.csdn.net/LeoForBest/article/details/79429955

  3. asp.net core中DockerFile文件中的COPY

    今天在ubuntu系统中使用docker部署asp.net core时遇到了一个问题,docker build 的时候总会在最后一步提示 lstat obj/Docker/publish: no su ...

  4. 汉诺塔问题php解决

    面向过程解决 <?php function hanio($n,$x,$y,$z){//把n个盘子,按照要求从x移到z,y是中介 //递归跳出条件 if($n==1){ move($n, $x, ...

  5. springmvc细节篇

    前面讲了入门篇,现在来了解下springmvc的细节.mvc框架都有请求映射.数据绑定.请求处理.视图解析这几个过程,现在我们来了解springmvc中的这些细节. 1.使用@RequestMappi ...

  6. swift的Hashable

    Conforming to the Hashable Protocol To use your own custom type in a set or as the key type of a dic ...

  7. 3942: [Usaco2015 Feb]Censoring

    3942: [Usaco2015 Feb]Censoring Time Limit: 10 Sec Memory Limit: 128 MB Submit: 964 Solved: 480 [Subm ...

  8. virtualbox+vagrant学习-4-Vagrantfile-4-Tips & Tricks

    Tips & Tricks Vagrantfile是一种非常灵活的配置格式.因为它只是Ruby,所以你可以用它做很多事情.然而,同样的道理,因为它是Ruby,所以有很多方法可以朝自己的脚开枪( ...

  9. R语法:<<-为全局变量赋值

    例:在函数内部为全局变量赋值 all_predata_time <- data.frame(pd=0.1,Row=1,preRow=0,pt=0.1,stasid='1',InitDate='1 ...

  10. selenium测试报告(含通过率统计图和失败截图)

    前言: 介绍的是含饼状统计图及失败截图的测试报告文件. 原文地址:https://testerhome.com/topics/9984 此版本增加了如下功能 测试报告完全汉化,包括错误日志的中文处理 ...