https://codeforces.com/contest/1114/problem/B

一开始叫我做,我是不会做的,我没发现这个性质。

其实应该很好想才对,至少要选m个元素,其中m个作为最大值,从总体上考虑的话,要是能区分哪些元素处于前m*k大,就把他们m个一组直接划分就好了。

魔理沙dalao说还不需要用sort来降序,用nth_element,我还在想怎么从序列中复原出标号,其实只需要在一起nth_element就好了。

#include<bits/stdc++.h>
using namespace std;
#define ll long long int n,m,k;
pair<int,int> a[];
int idx[]; int main(){
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<n;i++){
scanf("%d",&a[i].first);
a[i].second=i;
}
nth_element(a,a+m*k,a+n,greater<pair<int,int> >()); ll sum=;
for(int i=;i<m*k;i++){
sum+=a[i].first;
idx[i]=a[i].second;
}
printf("%lld\n",sum);
sort(idx,idx+m*k);
for(int i=;i<m*k;i++){
if(i%m==&&i){
if(i!=m)
printf(" ");
printf("%d",idx[i]);
}
}
printf("\n");
}

Codeforces - 1114B - Yet Another Array Partitioning Task - 构造 - 排序的更多相关文章

  1. CF#538(div2) B. Yet Another Array Partitioning Task 【YY】

    任意门:http://codeforces.com/contest/1114/problem/B B. Yet Another Array Partitioning Task time limit p ...

  2. B. Yet Another Array Partitioning Task ——cf

    B. Yet Another Array Partitioning Task time limit per test 2 seconds memory limit per test 256 megab ...

  3. CF1114B Yet Another Array Partitioning Task

    CF1114B Yet Another Array Partitioning Task 贪心,选择前 \(k*m\) 大的元素对答案进行贡献. 每次划分时,从当前位置往后扫,扫到 \(m\) 个前 \ ...

  4. Codeforces 959D. Mahmoud and Ehab and another array construction task(构造, 简单数论)

    Codeforces 959D. Mahmoud and Ehab and another array construction task 题意 构造一个任意两个数都互质的序列,使其字典序大等于a序列 ...

  5. 【Codeforces 1114B】Yet Another Array Partitioning Task

    [链接] 我是链接,点我呀:) [题意] 让你把数组分成k个连续的部分 使得每个部分最大的m个数字的和最大 [题解] 把原数组降序排序 然后选取前m*k个数字打标记 然后对于原数组 一直贪心地取 直到 ...

  6. CF1114B Yet Another Array Partitioning Task(贪心,构造题)

    我至今不敢相信我被这么一道简单的题卡了这么久……看来还是太弱了…… 题目链接:CF原网 题目大意:定义一个序列的“美丽度”为这个序列前 $m$ 大的数的和.现在有一个长度为 $n$ 的序列,你需要把它 ...

  7. D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学

    D. Mahmoud and Ehab and another array construction task 因子分解模板 题意 给出一个原序列a 找出一个字典序大于a的序列b,使得任意 \(i!= ...

  8. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  9. Codeforces Round #504 D. Array Restoration

    Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...

随机推荐

  1. C#语言循环语句for嵌套

  2. unix && linux

    区别和联系 Linux和UNIX的最大的区别是,前者是开发源代码的自由软件,而后者是对源代码实行知识产权保护的传统商业软件.这应该是他们最大的不同,这种不同体现在用户对前者有很高的自主权,而对后者却只 ...

  3. zookeeper 服务端上下线,客户端感知

    package pfs.y2017.m11.zookeeper.demo03; import java.util.ArrayList; import java.util.List; import or ...

  4. Animated progress view with CAGradientLayer(带翻译)

    Animated progress view with CAGradientLayer(带翻译)  Modern software design is getting flatter and thin ...

  5. 信雅达面试题atoi函数实现

    atoi函数: 功 能: 把字符串转换成整型数. 名字来源:ASCII to integer 的缩写. 原型: int atoi(const char *nptr); 函数说明 参数nptr字符串,如 ...

  6. Python开发【迭代器】

    1.迭代器 1.1.迭代器创建:指定数据创建迭代器(使用iter()和next() ) x = [1, 2, 3] #定义一个列表:<class 'list'> y = iter(x) # ...

  7. node.js内存泄露问题记录

    先说一下.事情的来龙去脉. 公司开发一款游戏棋牌游戏,服务端的开发是IO密集型,开发的时候,考虑过使用python,java,node.js. 终于选择了node.js(node.js宣传的杀手功能. ...

  8. 安装NLTK

    在网上找了一圈,没找到几个靠谱的安装流程,在http://nltk.org/install.html上找到各平台下安装流程: Windows平台: 以下操作假定你的机器上还没有安装Python,如果你 ...

  9. jQuery 工具函数

    jQuery工具函数 一.$.browser对象属性 属性列表 说明 webkit webkit相关浏览器则返回true,否则返回false,如google,傲游. mozilla mozilla相关 ...

  10. 树的深度优先遍历和广度优先遍历的原理和java实现代码

    import java.util.ArrayDeque; public class BinaryTree { static class TreeNode{ int value; TreeNode le ...