网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  PAT 甲级 1125 Chain the Ropes (25 分) 思路: 代码:

PAT 甲级 1125 Chain the Ropes (25 分) 思路: 代码:

分类: IT文章 • 2024-06-12 20:17:00

1.越先被折叠的绳子被折叠次数越多,让短的绳子先被折叠即可;
2.最后输出不大于绳子长度的最大整数;

代码:

#include<iostream>
#include<set>
using namespace std;
int main(){
	int n;
	cin>>n;
	multiset<int> st;
	for(int i=0;i<n;i++){
		int len;
		cin>>len;
		st.insert(len);
	}
	double len=0;
	multiset<int>::iterator it=st.begin();
	for(int i=0;i<2;i++,it++) len+=*it;
	len/=2;
	for(;it!=st.end();it++) len=(len+*it)/2;
	cout<<(int)len;
	return 0;
}

相关推荐

  • PAT 甲级 1126 Eulerian Path (25 分) 思路: 代码:
  • PAT 甲级 1127 ZigZagging on a Tree (30 分) 思路: 代码:
  • PAT 甲级 1131 Subway Map (30 分) 思路: 代码:
  • PAT 甲级 1125 Chain the Ropes (25 分) 思路: 代码:
  • PAT 甲级 1127 ZigZagging on a Tree (30 分) 思路: 代码:
  • PAT 甲级 1126 Eulerian Path (25 分) 思路: 代码:
  • PAT 甲级 1131 Subway Map (30 分) 思路: 代码:
  • PAT 甲级 1125 Chain the Ropes (25 分) 思路: 代码:
  • PAT (Advanced Level) Practice 1150 Travelling Salesman Problem (25分) (正常思路) 1.题目 2/题目分析 3.代码
  • PAT甲组 1010 Radix (二分) 1010 Radix (25分) Input Specification: Output Specification: Sample 题意 思路 代码
  • POJ 3250 单调栈
  • 利用套打和分栏巧妙来做商品价签
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号