CF436E Cardboard Box(贪心)】的更多相关文章

题面 CF436E Cardboard Box \(n\) 个关卡,对每个关卡可以花 \(a_i\) 时间得到 \(1\) 颗星,或花 \(b_i\) 时间得到 \(2\) 颗星,或不玩.问获得 \(m\) 颗星最少需要多少时间. 数据范围:\(1\le n\le 3\cdot 10^5\),\(1\le m\le 2n\),\(a_i<b_i\). 题解 蒟蒻做这题时已经知道是反悔贪心了,但是做了 \(4\) 个小时做不出来.于是去看题解,感觉这个 \(5\) 堆做法太非人类了,于是去看 CF…
题意 有nnn个关卡,第iii关可以花费aia_iai​的代价打一颗星,bib_ibi​的代价打两颗星.保证1≤ai<bi≤1091\le a_i<b_i\le10^91≤ai​<bi​≤109,问要达到www颗星最少花费. 题解 就是 hdu6698.Coinshdu 6698.Coinshdu6698.Coins 的弱化版. hduhduhdu多校赛上是要查询要达到1→2n1\to 2n1→2n的所有每个www的答案. 先把bi减去ai得到新的bi,要获取第二颗星的代价就是新的bi.…
Cardboard Box 贪了个半天贪不对, 我发现我根本就不会贪心. 我们先按b排序, 然后枚举选两颗心的b的最大值, 在这个之前的肯定都要选一个, 因为前面的要是一个都没选的话, 你可以把当前选两颗心的替换成前面选两颗心, 然后用平衡树或者线段树维护一下前k大和就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define P…
题面传送门 题意: 有 \(n\) 个关卡,第 \(i\) 个关卡玩到 \(1\) 颗星需要花 \(a_i\) 的时间,玩到 \(2\) 颗星需要 \(b_i\) 的时间.(\(a_i<b_i\)) 求玩到 \(w\) 颗星最少需要多少时间. \(1 \leq n \leq 3 \times 10^5\) yyq:"好题不常有,做过了就不能再错过了" 首先有一个显然的错误解法:初始将所有 \(a_i\) 压入优先队列,然后每次弹出优先队列中最小的值,如果它是一星的话就将 \(b_…
B. Box Permutation p is a sequence of integers p=[p1,p2,-,pn], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutations: [3,4,1,2], [1], [1,2]. The following sequences are n…
Cardboard Container Problem Description fidget spinners are so 2017; this years' rage are fidget cubes. A fidget cube is a cube with unit side lengths, which you hold in your hand and fidget with. Kids these days,right? You work in the planning depar…
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取模. 因为取模后至少减半, 复杂度$O(nlognlogC)$ 2. CF 431E Chemistry Experiment 大意: n个试管, 第$i$个试管有$a_i$单位水银, m个操作: 1, 修改$a_x$改为$v$. 2, 将$v$单位水倒入试管, 求一种方案使得有水的试管水银与水总量的最大…
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the…
495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized a…
题目链接 495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organiz…
地址:http://lbv.github.io/litjson/docs/quickstart.html LitJSON Quickstart Guide Introduction Quick Start Mapping JSON to objects and vice versa Readers and Writers Configuring the library’s behaviour Introduction JSON is a simple, yet powerful notation…
简介 ECMAScript 5.1 (或仅 ES5) 是ECMAScript(基于JavaScript的规范)标准最新修正. 与HTML5规范进程本质类似,ES5通过对现有JavaScript方法添加语句和原生ECMAScript对象做合并实现标准化.ES5还引入了一个语法的严格变种,被称为”严格模式(strict mode)”. 本文我们将介绍一些有用的改变和添加.关于完整列表,请参考官方ECMAScript语言规范附录D和E (PDF下载, 3MB),或者查看http://www.ecmas…
http://acm.sgu.ru/problem.php?contest=0&problem=495 学习:当一条路走不通,换一种对象考虑,还有考虑对立面. 495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is…
Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description   During the early stages of the Manhattan Project, the dangers of the new radioctive materials were not widely known. Vast new factory cities were bu…
题意: N个礼品箱, 每个礼品箱内的礼品只有第一个抽到的人能拿到. M个小孩每个人依次随机抽取一个,  求送出礼品数量的期望值. 1 ≤ N, M ≤ 100, 000 挺水的说..设f(x)表示前x个人都选择完成后礼品剩下数的期望值( f(0) = N ), 那么f(x) = f(x - 1) - f(x - 1) / N = f(x - 1) * (N - 1) / N (显然). 那么答案就是等于 N - N * [(N - 1) / N]^M. 后面部分可以用快速幂优化.时间复杂度O(l…
https://chortle.ccsu.edu/VectorLessons/index.html Chapter0 Points and Lines (已看) Chapter1 Vectors, Points, and Column Matrices (已看) Chapter2 Matrix Addition (已看) Chapter3 Vector Addition (已看) Chapter4 Vector Length (已看) Chapter5 Vector Direction (已看)…
https://www.ted.com/talks/tom_griffiths_3_ways_to_make_better_decisions_by_thinking_like_a_computer00:12If there's one city in the world where it's hard to find a place to buy or rent, it's Sydney. And if you've tried to find a home here recently, yo…
1,逆推状态:山东省赛2013年I题 Problem I: The number of steps Description Mary stands in a strange maze, the maze looks like a triangle(the first layer have one room,the second layer have two rooms,the third layer have three rooms …). Now she stands at the top p…
Lesson1  A puma at large Pumas are large, cat-like animals which are found in America. When reports came into London Zoo that a wild puma had been spotted forty-five miles south of London, they were not taken seriously. However, as the evidence began…
27w/m 76words Kidnappers are rarely interested in Animals, but they recently took considerable interest in Mrs Eleanor Ramsay's cat. Mrs Eleanor Ramsay, a very wealthy old lady,has shared a flat with her cat, Rastus, for a great many years. Rastus le…
495. Kids and Prizes Time limit per test: 0.25 second(s) Memory limit: 262144 kilobytes input: standard output: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized…
Kids and Prizes ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized a contest for kids for the best design of a cardboard box and selected M winners. There are N prizes for…
Description   During the early stages of the Manhattan Project, the dangers of the new radioctive materials were not widely known. Vast new factory cities were built to manufacture uranium and plu- tonium in bulk. Compounds and solutions of these sub…
A. Fox and Box Accumulation 题目连接: http://codeforces.com/contest/388/problem/A Description Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top…
Shadowman loves to collect box but his roommates woogieman and itman don't like box and so shadowman wants to hide boxes as many as possible. A box can be kept hidden inside of another box if and only if the box in which it will be held is empty and…
本文索引目录: 一.贪心算法的基本思想以及个人理解 二.汽车加油问题的贪心选择性质 三.一道贪心算法题点拨升华贪心思想 四.结对编程情况 一.贪心算法的基本思想以及个人理解: 1.1 基本概念: 首先我们从课本中仔细品读基本的贪心概念,顾名思义,贪心算法总是作出在当前看来最好的选择.也就是说贪心算法并不从整体最优考虑,它所作出的选择只是在某种意义上的局部最优选择.当然,希望贪心算法得到的最终结果也是整体最优的.虽然贪心算法不能对所有问题都得到整体最优解,但对许多问题它能产生整体最优解.如单源最短…
提交链接 http://codeforces.com/gym/100781/submit Description: Ada, Bertrand and Charles often argue over which TV shows to watch, and to avoid some of their fights they have finally decided to buy a video tape recorder. This fabulous, new device can reco…
题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来...... 先从小到大排一下序,然后从最上层向下找,只要能承受住重量就行.而且因为已经排序了找的都是尽量小的... #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib>…
Entertainment Box 题意: 有n个节目,每个节目给出开始时间(st)和结束时间(en): 有k个内存条这k个内存条可以同时存储节目.如果节目j的开始时间stj  大于等于节目i的结束时间,就可以放进内存条中: 问这k个内存条最多可以存储多少个节目. 思路:开一个multiset容器,开始压入k个0,表示k个内存条,这k个数表示存入的该内存条的最后一个节目的结束时间.将所有的节目按结束时间由小到大排序,然后遍历所有节目的开始时间,查找最后一个小于等于当前开始时间的结束时间,更新,记…
题意:你有\(n\)个礼物,礼物有自己的种类,你想将它们按种类打包送人,但是打包的礼物数量必须不同(数量,与种类无关),同时,有些礼物你想自己留着,\(0\)表示你不想送人,问你在送出的礼物数量最大的同时,尽可能的使自己喜欢的留下来,输出能送出的最大礼物数,以及这些礼物中自己不喜欢的数目. 题解:首先,我们肯定要让送出的礼物数最大,同时喜欢的最小,也就是送的礼物中,尽量让它的\(f\)是\(1\).这题考虑贪心,我们可以先对礼物数量进行排序,礼物数量相同让\(1\)多的排在前面,全部丢进优先队列…