PAT a1125题解
来源:互联网 发布:永宏编程手册 编辑:程序博客网 时间:2024/05/29 09:21
#include<cstdio> #include<stack> #include<vector> #include<algorithm> using namespace std; int main() { int N; scanf("%d", &N); vector<int> v(N,0); for (int i = 0; i < N; i++) { scanf("%d", &v[i]); } sort(v.rbegin(), v.rend()); stack<int> s; for (int i = 0; i < N; i++) { s.push(v[i]); } int a, b; while (s.size() > 1) { a = s.top(); s.pop(); b = s.top(); s.pop(); s.push((a + b) / 2); } printf("%d\n", s.top()); return 0; }
阅读全文
1 0
- PAT a1125题解
- PAT-A1125
- PAT A1125 Chain the Ropes
- PAT A1125. Chain the Ropes (25)(哈夫曼树)
- PAT 1001-1010 题解
- PAT 1011-1020 题解
- PAT 1021-1030 题解
- PAT 1031-1040 题解
- PAT 1041-1050 题解
- PAT 1051-1060 题解
- PAT(basic level)题解
- PAT乙级题解
- PAT题解目录
- PAT甲级题解目录
- PAT乙级题解目录
- PAT甲级1001题解
- PAT甲级1002题解
- PAT b1001-1005题解
- PAT a1107题解
- redis初理解
- caffe加层
- Linux命令详解-sar
- PAT a1124题解
- PAT a1125题解
- 初识Hdoop
- 使用Java实现多线程下载断点续传功能案例
- PAT a1126题解
- python : trans position cipher
- python3编码转换
- PAT a1127题解
- unity3D学习之声音的采集与处理-audio菜鸟笔记1
- PoEdu_Python_Lesson009_类的基础用法、使用dump写数据到json文件的注意点