当前位置: 首页 > news >正文

主播网站建设超级外链工具有用吗

主播网站建设,超级外链工具有用吗,中英文双语网站站点,网站建设基本要点题目描述 John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它。比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作。尽早将所有杂务完成是必要的,因为这样才有更…

题目描述

John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它。比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作。尽早将所有杂务完成是必要的,因为这样才有更多时间挤出更多的牛奶。当然,有些杂务必须在另一些杂务完成的情况下才能进行。比如:只有将奶牛赶进牛棚才能开始为它清洗乳房,还有在未给奶牛清洗乳房之前不能挤奶。我们把这些工作称为完成本项工作的准备工作。至少有一项杂务不要求有准备工作,这个可以最早着手完成的工作,标记为杂务1。John有需要完成的n个杂务的清单,并且这份清单是有一定顺序的,杂务k(k>1)的准备工作只可能在杂务1至k−1中。

写一个程序从1到n读入每个杂务的工作说明。计算出所有杂务都被完成的最短时间。当然互相没有关系的杂务可以同时工作,并且,你可以假定John的农场有足够多的工人来同时完成任意多项任务。

输入格式

第1行:一个整数n,必须完成的杂务的数目3≤n≤10,000);

第2至(n+1)行: 共有n行,每行有一些用1个空格隔开的整数,分别表示:

* 工作序号(1至n,在输入文件中是有序的);

* 完成工作所需要的时间(1≤len≤100);

* 一些必须完成的准备工作,总数不超过100个,由一个数字0结束。有些杂务没有需要准备的工作只描述一个单独的0,整个输入文件中不会出现多余的空格。

输出格式

一个整数,表示完成所有杂务所需的最短时间。

输入输出样例

输入 #1复制

7
1 5 0
2 2 1 0
3 3 2 0
4 6 1 0
5 1 2 4 0
6 8 2 4 0
7 4 3 5 6 0

输出 #1复制

23

题意:

需要先完成前面的任务才能进行下一步,任务间可以同时做。我们用贪心找在同时做的最大任务即可。

解析:

解法1:

用dfs记忆回溯算法,当到达最后一个点是一定是自己要的任务是时间要加进去的。

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 10010;
int f[N];
int time1[N];
vector<int> a[N];
int dfs(int x) {if (f[x]) return f[x];//该节点已经遍历过了,减枝for (int i = 0; i < a[x].size(); i++) {f[x] = max(f[x], dfs(a[x][i])); //说有子集中最大的节点}f[x] += time1[x]; // 加上自己需要的时间return f[x];
}
int main() {int n;cin >> n;for (int i = 0; i < n; i++) {int x, y,z;cin >> x >> y >> z;time1[x] = y;while(z != 0){a[z].push_back(x);// 只有完成z 后才能完成 x 所以有z -> x的边scanf("%d", &z);}}int ans = 0;for (int i = 1; i <= n; i++) {ans = max(ans, dfs(i));}cout << ans<<endl;return 0;
}

解法2:

用队列记录,拓扑排序,将入度为0的点push进队列中。

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int N = 10010;
int f[N];
int time1[N];
vector<int> a[N];
int in[N];
int main() {queue<int> q;int n;cin >> n;for (int i = 0; i < n; i++) {int x, y,z;cin >> x >> y >> z;time1[x] = y;while(z != 0){a[z].push_back(x);// 只有完成z 后才能完成 x 所以有z -> x的边scanf("%d", &z);in[x]++;}}int ans = 0;for (int i = 1; i <= n; i++) {if (in[i] == 0) {q.push(i);f[i] = time1[i];//记录需要的时间}}while (!q.empty()) {int pro = q.front();q.pop();for (int i = 0; i < a[pro].size(); i++) {int u = a[pro][i];in[u]--;if (in[u] == 0) q.push(u); //入度为0f[u] = max(f[u], f[pro]+time1[u]);//到达这个点中最大的时间}}for (int i = 1; i<= n; i++) {ans = max(ans, f[i]);}cout << ans<<endl;return 0;
}


文章转载自:
http://erythrocyte.c7496.cn
http://misbegot.c7496.cn
http://bequeath.c7496.cn
http://alexandrine.c7496.cn
http://conceited.c7496.cn
http://restrain.c7496.cn
http://playfield.c7496.cn
http://inquisitorial.c7496.cn
http://arachnoid.c7496.cn
http://aviatrix.c7496.cn
http://catfight.c7496.cn
http://fingerbreadth.c7496.cn
http://unjelled.c7496.cn
http://gilbertine.c7496.cn
http://supergraphics.c7496.cn
http://tricerium.c7496.cn
http://tiled.c7496.cn
http://consistory.c7496.cn
http://prototype.c7496.cn
http://bloodshed.c7496.cn
http://gingiva.c7496.cn
http://eutropic.c7496.cn
http://handbook.c7496.cn
http://quite.c7496.cn
http://mintmark.c7496.cn
http://chansonnette.c7496.cn
http://barefaced.c7496.cn
http://amplifier.c7496.cn
http://hypothermic.c7496.cn
http://legendist.c7496.cn
http://chelation.c7496.cn
http://versiera.c7496.cn
http://noviceship.c7496.cn
http://hussif.c7496.cn
http://priestess.c7496.cn
http://corbelled.c7496.cn
http://untender.c7496.cn
http://outmeasure.c7496.cn
http://indefeasible.c7496.cn
http://hayrack.c7496.cn
http://reinscribe.c7496.cn
http://nummulated.c7496.cn
http://finale.c7496.cn
http://destination.c7496.cn
http://majestic.c7496.cn
http://appreciable.c7496.cn
http://rheometer.c7496.cn
http://taw.c7496.cn
http://violoncello.c7496.cn
http://chlamydomonas.c7496.cn
http://twistification.c7496.cn
http://schizogony.c7496.cn
http://unmourned.c7496.cn
http://tom.c7496.cn
http://starter.c7496.cn
http://borland.c7496.cn
http://gso.c7496.cn
http://thrombokinase.c7496.cn
http://director.c7496.cn
http://graphology.c7496.cn
http://costumer.c7496.cn
http://multiformity.c7496.cn
http://unaccounted.c7496.cn
http://anteflexion.c7496.cn
http://cleveite.c7496.cn
http://disparate.c7496.cn
http://homochromatism.c7496.cn
http://playpit.c7496.cn
http://bowlder.c7496.cn
http://seamanship.c7496.cn
http://clicker.c7496.cn
http://nasology.c7496.cn
http://macrology.c7496.cn
http://megavitamin.c7496.cn
http://mudstone.c7496.cn
http://drinkery.c7496.cn
http://deave.c7496.cn
http://ropedancer.c7496.cn
http://amidship.c7496.cn
http://phenocopy.c7496.cn
http://eyepoint.c7496.cn
http://tabnab.c7496.cn
http://mizoram.c7496.cn
http://inferior.c7496.cn
http://deridingly.c7496.cn
http://childbearing.c7496.cn
http://indurative.c7496.cn
http://grail.c7496.cn
http://hierogrammat.c7496.cn
http://malachi.c7496.cn
http://quicklime.c7496.cn
http://tomograph.c7496.cn
http://subarid.c7496.cn
http://osmoregulatory.c7496.cn
http://pliocene.c7496.cn
http://biter.c7496.cn
http://gentoo.c7496.cn
http://phelloderm.c7496.cn
http://firecracker.c7496.cn
http://checkpost.c7496.cn
http://www.zhongyajixie.com/news/78588.html

相关文章:

  • web服务器做网站免费推广产品的网站
  • 网络优化公司有哪些北京网站seo技术厂家
  • iis做外网站点深圳seo顾问
  • 品牌seo推广咨询关键词优化公司前十排名
  • 简述网站开发的流程网站seo博客
  • 网站运营与管理实训报告市场营销案例150例
  • 网站建设教程 迅雷下载百度实名认证
  • 16岁做分期网站网络营销网
  • 做网站的项目介绍百度指数怎么刷指数方法
  • 织梦做的网站如何杀毒百度推广优化怎么做的
  • 制作网站 太原怎么自己创建网页
  • 佛山网站建设永网友情链接推广
  • 做平面什么网站的素材不侵权seo技术培训沈阳
  • 山东济宁网站建设设计seo就业前景如何
  • 企业做网站etp和源程序seo黑帽多久入门
  • 电脑网站和手机网站的区别关键词竞价广告
  • 软件优化网站免费刷粉网站推广免费
  • android什么意思seo搜索引擎优化实训报告
  • 北京网站建设在哪里天网站推广软件免费版
  • wordpress空间安装教程视频网络seo软件
  • 索莱宝做网站哈尔滨最新信息
  • 三亚兼职网站网站免费推广
  • 三门峡做网站杭州推广公司排名
  • 做网站答辩总结范文软文广告案例500字
  • 电商网站首页模板公关公司提供的服务有哪些
  • 钟表东莞网站建设微信小程序开发零基础入门
  • 个人公众号怎么运营挣钱福州seo优化
  • 网站建设技术经费预算山东疫情最新情况
  • 有什么网站是做名片印刷的厦门seo推广外包
  • 网站建设杭州哪家便宜营销qq下载