Codeforces 439B Devu, the Dumb Guy
来源:互联网 发布:用java编写三角形 编辑:程序博客网 时间:2024/05/16 07:57
题目链接:Codeforces 439B Devu, the Dumb Guy
排序,先学章节少的。
#include <iostream>#include <cstdio>#include <algorithm>using namespace std;const int MAX_N = 100000 + 100;int arr[MAX_N];int main(){ int n, k; scanf("%d%d", &n, &k); for(int i = 0; i < n; i++) scanf("%d", &arr[i]); sort(arr, arr + n); __int64 now = k, cost = 0; for(int i = 0; i < n; i++) { if(now < 1) now = 1; cost += now * arr[i]; now--; } printf("%I64d\n", cost); return 0;}
0 0
- Codeforces 439B Devu, the Dumb Guy
- Codeforces 439 B. Devu, the Dumb Guy
- CodeForces 439B Devu, the Dumb Guy
- CodeForces 439B Devu, the Dumb Guy
- Codeforces 439B Devu, the Dumb Guy
- Codeforces 439B Devu, the Dumb Guy(贪心)
- B. Devu, the Dumb Guy
- B. Devu, the Dumb Guy
- Codeforces Round #251 (Div. 2) 439B Devu, the Dumb Guy(贪心)
- Codeforces Round #251(Div. 2) 439B. Devu, the Dumb Guy 贪心
- Devu, the Dumb Guy
- Codeforces 439A Devu, the Singer and Churu, the Joker
- Codeforces 439 A. Devu, the Singer and Churu, the Joker
- Codeforces 439A Devu, the Singer and Churu, the Joker
- codeforces 439A Devu, the Singer and Churu, the Joker
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439C Devu and Partitioning of the Array(模拟)
- Codeforces 439C Devu and Partitioning of the Array
- Codeforces 439A Devu, the Singer and Churu, the Joker
- 浏览器兼容问题汇总
- ZOJ-1831
- VS08调C数据结构
- 第三十七题 求取二叉树中节点的最低公共节点
- Codeforces 439B Devu, the Dumb Guy
- 第一篇——第一文 SQL Server 备份基础
- Hadoop2.2.0下通过编译单词统计例子WordCount.java熟悉如何编译自己的程序
- Android SDK 下载地址
- css和js的浏览器不兼容问题汇总
- C和指针 学习笔记-1.编译与链接
- 青蛙的约会
- 带权二分图最佳匹配KM算法模板
- 华为OJ_1950_句子逆序