Codeforces 332 C

我爱对拍,对拍使我快乐。。。

题意:有\(n\)个议题,学生们会让议会同意\(p\)个,其中主席会执行\(k\)个,

每一个议题执行后主席会掉\(a_i\)的头发,不执行后议会会增加\(b_i\)的不开心值,

然后主席想让议会的不开心值最小,如果有多重方案就选自己头发掉的最少的;

而学生们想让主席的头发掉的最多,如果有多种方案让议会的不开心值最大。

问让议会同意哪\(p\)个会达到最好的效果。

思路1:

这是我的不对的思路。

(虽然没提交

我们首先将所有的数按照\(b_i\)从大到小排,如相等按照\(a_i\)从小到大排。

然后把前\(n-p+k\)个按照\(a_i\)从大到小排,

然后取前\(k\)个作为主席执行的

再向后延\(p-k\)个作为主席不执行的

然后其实这个是错的。

如果所有的\(a\)都相等,那么这个答案就不对

(我只是对拍出来的,并不会证。

思路2:

这是对的思路。

首先我们枚举主席执行的和不执行的所取的议题的范围的分界线\(i\)。

然后我们对于所有的\(i\)要找出主席取的和不取的最好效果的那些议题。

那就从前往后扫一遍,找出取的;

从后往前再扫一遍,找出不取的。然后取或不取都是放到优先队列里面找最大的\(a\)或\(b\)。

然后看答案最大的就可以了。

【Codeforces 332C】Students' Revenge的更多相关文章

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

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

  2. 【55.70%】【codeforces 557A】Ilya and Diplomas

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

  3. 【24.67%】【codeforces 551C】 GukiZ hates Boxes

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

  4. 【24.34%】【codeforces 560D】Equivalent Strings

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

  5. 【19.46%】【codeforces 551B】ZgukistringZ

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

  6. 【74.89%】【codeforces 551A】GukiZ and Contest

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

  7. 【codeforces 758C】Unfair Poll

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

  8. 【codeforces 762B】USB vs. PS/2

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

  9. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

随机推荐

  1. java - Jsoup原理

    https://blog.csdn.net/xh16319/article/details/28129845 http://www.voidcn.com/article/p-hphczsin-ru.h ...

  2. 教你读懂vue源码技术教程

    由于 Vue 的源码采用 ES6,所以你至少应该掌握 ES6 才能看得懂,其次你最好对 package.json 中的字段的作用有所了解.由于 Vue 使用 Rollup 构建,所以你不了解 Roll ...

  3. loadsh常用函数

    此篇文章会记录常用的lodash函数 防抖函数:_.debounce() 创建一个去缓冲函数,该函数将自上次调用函数以来经过设置的等待毫秒后调用func. 去缓冲函数带有一个取消方法来取消延迟的fun ...

  4. React 入门学习笔记整理(三)—— 组件

    1.定义组件 1)函数组件 function GreateH(props){ return <div> <h2>hello,{props.name}</h2> &l ...

  5. SSM 开发 Tars

    目录结构 tars生成的文件当成 controller 来调用 service ,service 调用 mapper POM 注意如果 mybatis是3.4.1 spring 是4.1.14的话, ...

  6. 聊聊setTimeout和setInterval线程

    在聊setTimeout和setInterval这两个事件的前,先聊另外一个与之密切关联的知识点,那就是线程(thread).而线程有常常跟另外一个词语--“进程”一起出现.那么何为线程?何为线程呢? ...

  7. vue权威指南笔记01——样式的设置

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. K邻近分类算法

    # -*- coding: utf-8 -*- """ Created on Thu Jun 28 17:16:19 2018 @author: zhen "& ...

  9. [20180713]关于hash join 测试中一个疑问.txt

    [20180713]关于hash join 测试中一个疑问.txt --//上个星期做的测试,链接: http://blog.itpub.net/267265/viewspace-2157424/-- ...

  10. EasyUI报错 $(...).accordion is not a function

    参考资料: https://stackoverflow.com/questions/9017634/accordion-is-not-a-function 原因:加载了2次jquery js文件