【链接】 我是链接,点我呀:)

【题意】

让你把数组分成k个连续的部分
使得每个部分最大的m个数字的和最大

【题解】

把原数组降序排序
然后选取前m*k个数字打标记
然后对于原数组
一直贪心地取
直到这个区间选了m个打标记的数字为止。
然后就划分一个区间>_

【代码】

import java.io.*;
import java.util.*; public class Main { static int N = (int)2e5;
static InputReader in;
static PrintWriter out; static class Pair implements Comparable<Pair>{
int x,id; public Pair(int x,int id) {
this.x = x;this.id = id;
} @Override
public int compareTo(Pair o) {
// TODO Auto-generated method stub
return o.x-this.x;
} } public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
} static class Task{
public void solve(InputReader in,PrintWriter out) {
int n,m,k;
int []a = new int [N+10];
int []tag = new int [N+10];
Pair []b = new Pair[N+10];
n = in.nextInt();m = in.nextInt();k = in.nextInt();
for (int i = 1;i <= n;i++) a[i] = in.nextInt();
for (int i = 1;i <= n;i++) {
b[i] = new Pair(a[i],i);
}
Arrays.sort(b, 1,n+1);
long ans1 = 0;
for (int i = 1;i <=m*k;i++) {
tag[b[i].id]= 1;
ans1 = ans1 + b[i].x;
}
out.println(ans1);
int cnt = 0;
int cnt2 = 0;
for (int i = 1;i <= n;i++){
if (tag[i]==1) {
cnt++;
if (cnt==m) {
cnt = 0;
out.print(i+" ");
cnt2++;
if (cnt2==k-1){
return;
}
}
}
}
}
} static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer; public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
} public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
} public int nextInt() {
return Integer.parseInt(next());
}
}
}

【Codeforces 1114B】Yet Another Array Partitioning Task的更多相关文章

  1. 【24.17%】【codeforces 721D】Maxim and Array

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【codeforces 754A】Lesha and array splitting

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【Codeforces 258B】 Sort the Array

    [题目链接] http://codeforces.com/contest/451/problem/B [算法] 模拟 在序列中找到一段单调递增的子序列,将这段序列反转,然后判断序列是否变得单调递增,即 ...

  4. 【codeforces 719E】Sasha and Array

    [题目链接]:http://codeforces.com/contest/719/problem/E [题意] 给你一个数列,有两种操作1 l r x 给[l,r]区间上的数加上x, 2 l r 询问 ...

  5. 【44.19%】【codeforces 727C】Guess the Array

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【Codeforces 1042D】Petya and Array

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 把a[i]处理成前缀和 离散化. 枚举i从1..n假设a[i]是区间和的a[r] 显然我们需要找到a[r]-a[l]<t的l的个数 即a ...

  7. 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 ...

  8. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  9. 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 ...

随机推荐

  1. YTU 2732:3798-Abs Problem

    2732: 3798-Abs Problem 时间限制: 1 Sec  内存限制: 128 MB  Special Judge 提交: 167  解决: 60 题目描述 Alice and Bob i ...

  2. bzoj 3312 No Change

    题目大意: 到商场购物,他的钱包里有K个硬币 想按顺序买 N个物品,第i个物品需要花费c(i)块钱 在依次进行的购买N个物品的过程中,可以随时停下来付款,每次付款只用一个硬币 支付购买的内容是从上一次 ...

  3. E20170804-mk

    epic n. 史诗; 叙事诗; 史诗般的作品; estimate vt. 估计,估算; 评价,评论; 估量,估价; Sprint  vi. 冲刺,全速短跑; n. 全速短跑; 速度或活动的突然爆发; ...

  4. es6 import 与 export

    1.export 命令 export 命令用于规定模块的对外接口. 一个模块就是一个独立的文件.该文件内部所有的变量,外部无法获取.要想外部能够读取模块内部的某个变量,就必须使用 export 关键字 ...

  5. codevs2147数星星(哈希)

    2147 数星星  时间限制: 3 s  空间限制: 64000 KB  题目等级 : 钻石 Diamond   题目描述 Description 小明是一名天文爱好者,他喜欢晚上看星星.这天,他从淘 ...

  6. win10 激活方法 (各版本)

    很多人都在找Win10专业版永久密钥,其实win10激活码不管版本新旧都是通用的,也就是说一个win10专业版key,可以同时激活windows10专业版1809.1803.1709.1703.160 ...

  7. InterferenceSignal-----------挺简单的 一道题 就是英语不好

    InterferenceSignal 时间限制: 2000ms内存限制: 128000KB 64位整型: Java 类名: 上一题 提交 运行结果 统计 讨论版 下一题 类型: 没有 添加 题目描述 ...

  8. vagrant使用centos的环境安装..

    vagrant这货挺好用的..简要就是, 下好virtualbox, vagrant, 然后下个你需要的box. 然后vagrant box add boxname boxpath就行. 然后在合适的 ...

  9. HDU4340 Capturing a country DP

    自己原来写的两个维度的DP有错,看了半天这个大牛的blog.http://blog.csdn.net/cyberzhg/article/details/7840922 题意:A军队和B军队要一起占领一 ...

  10. FFmpeg编译Android版本

    FFmpeg是很好用的一个音视频库,功能强大,但是用起来并不是很方便.之前一直不想用FFmpeg,因为感觉编译太麻烦,但是到了不得不用的时候了,没办法,参考了网上大神的方法,在这里自己也记录一下方便以 ...