CodeForces 313 C.Ilya and Matrix(构造)
来源:互联网 发布:人工智能对政治的影响 编辑:程序博客网 时间:2024/05/29 12:28
Description
给出
Input
第一行输入一个整数
Output
输出由这
Sample Input
4
1 2 3 4
Sample Output
14
Solution
通过适当的构造可以使得在递归求权值时,第一次取到最大值,第二次取到最大的4个值,第三次取到最大的
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 2222222int n;ll a[maxn];bool cmp(ll a,ll b){ return a>b;}int main(){ while(~scanf("%d",&n)) { for(int i=1;i<=n;i++)scanf("%I64d",&a[i]); sort(a+1,a+n+1,cmp); for(int i=2;i<=n;i++)a[i]+=a[i-1]; ll ans=0; for(int i=1;i<=n;i*=4)ans+=a[i]; printf("%I64d\n",ans); } return 0;}
阅读全文
0 0
- CodeForces 313 C.Ilya and Matrix(构造)
- codeforces 313C. Ilya and Matrix
- Codeforces 313C Ilya and Matrix【思维】
- C. Ilya and Matrix
- Codeforce 313C Ilya and Matrix
- codeforces 525C Ilya and Sticks(简单贪心)
- Codeforces 842 C. Ilya And The Tree (dfs)
- Codeforces 842 C. Ilya And The Tree (dfs)
- codeforces 525C Ilya and Sticks
- CodeForces-525C Ilya and Sticks
- Codeforces 525C:Ilya and Sticks
- CodeForces 525C Ilya and Sticks
- Codeforces 525C. Ilya and Sticks
- Codeforces 525C Ilya and Sticks 【数学】
- Codeforces 525C Ilya and Sticks
- CodeForces 525C . Ilya and Sticks
- Codeforces 525C Ilya and Sticks【贪心】
- Codeforces 842C Ilya And The Tree
- POJ2488/openjudge 1490 A Knight's Journey 解题报告(dfs)
- Django-深度分析Django基于类的视图(2)(翻译)
- [Windows驱动开发](一)序言
- 在JAVA中,如何跳出当前的多重嵌套循环?
- 使用Hibernate+struts实现添加用户和查看用户
- CodeForces 313 C.Ilya and Matrix(构造)
- ACDI事物的四大特性
- 水塘抽样算法
- hdu 1370 中国剩余定理+exgcd
- [Windows驱动开发](二)基础知识——数据结构
- MySQL 命令环境变量设置方法
- [Windows驱动开发](三)基础知识——驱动例程
- NYOJ【169】素数【最近素数】
- [Windows驱动开发](四)内存管理