poj 1700 贪心过河
来源:互联网 发布:脸型测试软件 编辑:程序博客网 时间:2024/05/22 10:44
#include<cstdio>#include<algorithm>#define max(x,y) ((x)>(y)?(x):(y))using namespace std;int main(){int T,n,t1,t2,res;int d[1100];scanf("%d",&T);while(T--){int res=0;scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&d[i]);sort(d,d+n); for(int i=n-1;i>=0;i-=2){if(i==2){res+=d[0]+d[1]+d[2];break; } if(i==1) { res+=d[1]; break; }if(i==0){res+=d[0];break;} t1=d[0]+2*d[1]+d[i];t2=2*d[0]+d[i-1]+d[i];if(t1>t2)res+=t2;elseres+=t1;}printf("%d\n",res); } }
0 0
- poj 1700 过河贪心
- poj 1700 贪心过河
- POJ-1700 过河问题【贪心】
- 贪心-POJ 1700 过河问题
- poj 1700 n人过河(贪心)
- POJ 1700 经典过河问题(贪心)
- POJ-1700 &&NYOJ 47 过河问题【贪心】
- poj 1700(贪心——两人坐船过河)
- POJ 1700 & NYLG 47 过河问题(贪心 || DP)
- POJ 1700 Crossing River 过河问题 贪心法
- poj 2573 Bridge(贪心:过河问题)
- poj 1700过河问题
- poj 1700过河问题
- poj 1700 过河问题
- poj 1700 过河问题
- POJ 1700(过河问题)
- POJ 1700(过河问题)
- 【贪心DP】过河问题
- 为 instance 配置静态 IP
- 最简单的 RabbitMQ 监控方法
- instance “error” 了怎么办?- 每天5分钟玩转 OpenStack(159)
- Troubleshooting OpenStack 瘫痪
- 树状数组
- poj 1700 贪心过河
- scanf()、gets()和getline()读取输入
- asp.net 删除确认对话框
- 解决YUM下Loaded plugins: fastestmirror Determining fastest mirrors
- springmvc中forward和redirect
- asp.net 捕获用户操作 确认删除
- c代码处理
- 多条件筛选界面DropDownMenu使用总结
- 争取做一个早睡早起,有思想也有的趣程序员