洛谷 P1113 杂务(vector)
2024-09-01 07:33:25
题目传送门
解题思路:
本题说有些杂务是有前提条件的,而有一个特性就是某个杂务的前提一定在这个杂务前面输入,那么,这个题就瞬间沦为了黄题.对于那些有前提条件的杂务,我们只需要找它的前提条件中最晚完成的那个加上自己的时间就是这个杂务最早完成的时间.再在全部杂务中找最晚的那个,就是答案.
AC代码:
#include<cstdio>
#include<iostream>
#include<vector> using namespace std; int n,p,a;
struct kkk {
int v;
vector<int> l;
}e[]; inline void solve() {
for(int i = ;i <= n; i++) {
int ans = ;
for(int j = ;j < e[i].l.size(); j++)
ans = max(ans,e[e[i].l[j]].v);
e[i].v += ans;
a = max(a,e[i].v);
}
} int main()
{
scanf("%d",&n);
for(int i = ;i <= n; i++) {
scanf("%d%d",&p,&e[i].v);
while(true) {
scanf("%d",&p);
if(p == ) break;
e[i].l.push_back(p);
}
}
solve();
printf("%d",a);
return ;
}
最新文章
- [LeetCode] Meeting Rooms 会议室
- iis上如何架设HTTPS网站
- USB hacker Collection
- 解决Only a type can be imported. com.mysql.jdbc.Connection resolves to a package的报错问题
- java内存溢出分析(二)
- Go 命令之 godep
- SSIS -->;>; Variable
- Android下拉刷新-SwipeRefreshLayout,RecyclerView完全解析之下拉刷新与上拉加载SwipeRefreshLayout)
- NSMutableArray 排序
- JavaScript 风格指导(Airbnb版)
- sublime text There are no packages 解决!
- 向Int数组插入随机1到100
- 纯js实现积木(div)拖动效果
- Framework7功能齐全的 iOS7 App 前端框架
- 设计模式 ( 十四 ) 迭代器模式Iterator(对象行为型)
- ACL in 和 out 区别 (重要)
- 控制结构(1) 分枝/叶子(branch/leaf)
- 【Python 22】52周存钱挑战2.0(列表list和math函数)
- mobile_音悦台
- word中替换【换行符】与【回车符】
热门文章
- code first网站发布后数据表中没有数据问题
- USB2.0主机控制器 UPD720114 简单详解
- spring的一些annotation
- Hibernate--起步
- opencv python运动人体检测
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-text-width
- ES query does not support [auto_generate_synonyms_phrase_query]
- C# Stream篇(二) -- TextReader 和StreamReader
- Inheritance and the prototype chain 继承和 原型 链
- Dynamic Route Matching Vue路由(1)