topcoder powerOutage
来源:互联网 发布:淘宝客提现规则 编辑:程序博客网 时间:2024/06/03 11:34
#include<iostream>
#include<vector>
using namespace std;
int maxDuctLength(vector<int>fromJunction,vector<int>toJunction,vector<int>ductLength,int ductNumber)
{
int result=0;
for(size_t i=0;i<fromJunction.size();++i)
{
if(ductNumber==fromJunction[i])
result=max(result,ductLength[i]+maxDuctLength(fromJunction,toJunction,ductLength,toJunction[i]));
}
return result;
}
int estimateTimeOut(vector<int>fromJunction,vector<int>toJunction,vector<int>ductLength)
{
int result=-maxDuctLength(fromJunction,toJunction,ductLength,0);
for(size_t i=0;i<ductLength.size();++i)
{
result+=2*ductLength[i];
}
return result;
}
int main()
{
int a[]={0,0,0,1,4,4,6,7,7,7,20};
vector<int> fromJunction(a,a+sizeof(a)/sizeof(int));
int b[]={1,3,4,2,5,6,7,20,9,10,31};
vector<int> toJunction(b,b+sizeof(b)/sizeof(int));
int c[]={10,10,100,10,5,1,1,100,1,1,5};
vector<int> ductLength(c,c+sizeof(c)/sizeof(int));
cout<<estimateTimeOut(fromJunction,toJunction,ductLength)<<endl;
return 0;
}
#include<vector>
using namespace std;
int maxDuctLength(vector<int>fromJunction,vector<int>toJunction,vector<int>ductLength,int ductNumber)
{
int result=0;
for(size_t i=0;i<fromJunction.size();++i)
{
if(ductNumber==fromJunction[i])
result=max(result,ductLength[i]+maxDuctLength(fromJunction,toJunction,ductLength,toJunction[i]));
}
return result;
}
int estimateTimeOut(vector<int>fromJunction,vector<int>toJunction,vector<int>ductLength)
{
int result=-maxDuctLength(fromJunction,toJunction,ductLength,0);
for(size_t i=0;i<ductLength.size();++i)
{
result+=2*ductLength[i];
}
return result;
}
int main()
{
int a[]={0,0,0,1,4,4,6,7,7,7,20};
vector<int> fromJunction(a,a+sizeof(a)/sizeof(int));
int b[]={1,3,4,2,5,6,7,20,9,10,31};
vector<int> toJunction(b,b+sizeof(b)/sizeof(int));
int c[]={10,10,100,10,5,1,1,100,1,1,5};
vector<int> ductLength(c,c+sizeof(c)/sizeof(int));
cout<<estimateTimeOut(fromJunction,toJunction,ductLength)<<endl;
return 0;
}
0 0
- topcoder powerOutage
- TopCoder
- topcoder
- Topcoder
- topcoder
- topcoder
- Topcoder
- TOPCODER交流
- topcoder 小结
- TopCoder介绍
- topcoder是什么?
- TopCoder教程
- TopCoder简介
- TopCoder入门教程
- topcoder入门
- topcoder配置
- TopCoder入门教程
- [Topcoder] SRM474
- HDU 10722 && nyoj 483 Nightmare【bfs】
- MongoDB学习一
- javascript通用事件封装
- Io第一天作业
- Mybatis源码研究7:缓存的设计和实现
- topcoder powerOutage
- 关于struts2中ModelDriven的笔记
- linux学习笔记0.2---gstreamer命令
- Spring简介
- oracle 表空间查看
- PAT Advanced 1012
- mysql
- iOS 内存管理 (有ARC)
- 使用HelloCharts开源图表库制作柱状图