[USACO10FEB]给巧克力Chocolate Giving】的更多相关文章

题目描述 Farmer John is distributing chocolates at the barn for Valentine's day, and B (1 <= B <= 25,000) of his bulls have a special cow in mind to receive a chocolate gift. Each of the bulls and cows is grazing alone in one of the farm's N (2*B <=…
https://www.luogu.org/problem/show?pid=2984 题目描述 Farmer John is distributing chocolates at the barn for Valentine's day, and B (1 <= B <= 25,000) of his bulls have a special cow in mind to receive a chocolate gift. Each of the bulls and cows is graz…
题目链接:https://www.luogu.org/problemnew/show/P2984 练习SPFA,把FJ当做起点,求出到所有牛的最短路,再把两个牛的相加. #include <cstdio> #include <queue> #include <iostream> #include <algorithm> #include <cstring> using namespace std; ; const int inf = 0x7fff…
题意简叙: FarmerFarmerFarmer JohnJohnJohn有B头奶牛(1<=B<=25000)(1<=B<=25000)(1<=B<=25000),有N(2∗B<=N<=50000)N(2*B<=N<=50000)N(2∗B<=N<=50000)个农场,编号1−N1-N1−N,有M(N−1<=M<=100000)M(N-1<=M<=100000)M(N−1<=M<=100000)条双…
P2985 [USACO10FEB]吃巧克力Chocolate Eating 题目描述 Bessie has received N (1 <= N <= 50,000) chocolates from the bulls, but doesn't want to eat them too quickly, so she wants to plan out her chocolate eating schedule for the next D (1 <= D <= 50,000)…
P2983 [USACO10FEB]购买巧克力Chocolate Buying 题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of choc…
P2983 [USACO10FEB]购买巧克力Chocolate Buying 题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of choc…
购买巧克力Chocolate Buying 乍一看以为是背包,然后交了一个感觉没错的背包上去. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; //Mystery_Sky // #define M 10000000 #define ll long long ll f[M]; ll p[M], num[M], s…
题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of chocolate has price P_i (1 <= P_i <= 1…
题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of chocolate has price P_i (1 <= P_i <= 1…
题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of chocolate has price P_i (1 <= P_i <= 1…
题目传送门 继续dp刷题计划,看到这道题,第一眼感觉不就是显然的完全背包嘛.把背包打完要开始填充数组大小的时候成为了mengbier,发现数据极大,达到了1e18.显然这不是一道平凡的背包题目. 于是看了题解.wtf?这题是贪心??? emmm冷静分析:首先我们比较背包模型和这个模型,背包花费这一定的体积,那些价值一定会获得.而这个模型中,我们每花费一定的钱(体积),却只能满足一只奶牛.这是本题的关键. 那么就很难继续满足完全背包的性质了. 真想用背包?看到讨论里有人说如果这题写背包,那也得是多…
https://www.luogu.org/problem/show?pid=2983 题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of…
题目描述 Bessie拿到了N (1 <= N <= 50,000)块巧克力.她决定想个办法吃掉这些巧克力,使得它在吃巧克力的这段时间里,最不开心的一天尽可能的开心.并且一共吃D (1 <= D <= 50,000)天. 每块巧克力有一个开心值H_i (1 <= H_i <= 1,000,000),当某天你吃下那块巧克力时,你将获得那块巧克力的开心值.每一天的开心值是所有当天吃掉的巧克力的总开心值之和.每天晚上Bessie睡觉之后,它的开心值会减半.也就是说,比如昨天B…
题目描述 Bessie and the herd love chocolate so Farmer John is buying them some. The Bovine Chocolate Store features N (1 <= N <= 100,000) kinds of chocolate in essentially unlimited quantities. Each type i of chocolate has price P_i (1 <= P_i <= 1…
题目:洛谷P2985. 题目大意:有n块巧克力要吃d天,并且只能按顺序吃.一块巧克力有一个开心值,吃了就能增加开心值.一个人初始开心值为0,且每天早上开心值变为原来的一半.问如何吃巧克力才能使开心值最小的一天开心值最大(每天都按吃完巧克力后计算),且需要输出方案. 解题思路:最大化最小值问题,用二分答案. 贪心地扫描,对于一个答案,如果开心值不到这个答案,就一直吃巧克力即可. 最后输出吃的方案时也用此种贪心法. 注意如果最后巧克力没有吃完,则在最后一天全部吃掉. C++ Code: #inclu…
题目链接 Solution 先直接二分答案,然后贪心判断,一旦少于答案就吃一块. 思路很简单,有一点细节. 一天内可以不吃巧克力. 注意处理最后时没吃完的全部在最后一天吃完. Code #include<bits/stdc++.h> #define ll long long #define N 50008 #define inf 0x3f3f3f3f3f3f3f using namespace std; void in(ll &x) { char ch=getchar();ll f=1…
传送门 按价格排序后贪心 ——代码 #include <cstdio> #include <iostream> #include <algorithm> int n; long long m, ans; struct node { long long x, y; }p[]; inline long long read() { , f = ; char ch = getchar(); ; ) + (x << ) + ch - '; return x * f;…
洛谷 P2984 [USACO10FEB]给巧克力Chocolate Giving 洛谷传送门 JDOJ 2680: USACO 2010 Feb Silver 2.Chocolate Giving JDOJ传送门 Description Farmer John is distributing chocolates at the barn for Valentine's day, and B (1 <= B <= 25,000) of his bulls have a special cow…
裸最短路.. ------------------------------------------------------------------------------------ #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue>   #define rep( i , n ) for( int i = 0 ; i &…
2015: [Usaco2010 Feb]Chocolate Giving Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 269  Solved: 183[Submit][Status] Description Farmer John有B头奶牛(1<=B<=25000),有N(2*B<=N<=50000)个农场,编号1-N,有M(N-1<=M<=100000)条双向边,第i条边连接农场R_i和S_i(1<=R_i&…
P2983 [USACO10FEB]购买巧克力 题解 注意题目开 long long 贪心策略:价格从低到高,买够为止 反证:若剩下的有一个K”,比K小,那么交换,稳赚不赔 所以,在买K之前,所有比他便宜的都买完了 代码 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<cstring> #…
Description Farmer John有B头奶牛(1<=B<=25000),有N(2*B<=N<=50000)个农场,编号1-N,有M(N-1<=M<=100000)条双向边,第i条边连接农场R_i和S_i(1<=R_i<=N;1<=S_i<=N),该边的长度是L_i(1<=L_i<=2000).居住在农场P_i的奶牛A(1<=P_i<=N),它想送一份新年礼物给居住在农场Q_i(1<=Q_i<=N)的…
http://www.lydsy.com/JudgeOnline/problem.php?id=2015 这种水题真没啥好说的.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> using namespace s…
因为是双向边,所以相当于两条到1的最短路和,先跑spfa然后直接处理询问即可 #include<iostream> #include<cstdio> #include<queue> using namespace std; const int N=50005,inf=1e9; int n,m,b,h[N],cnt,dis[N]; bool v[N]; struct qwe { int ne,to,va; }e[N<<2]; int read() { int…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
大家注意:本次作业稍有增加,由于放假期间大家空闲时间比较充足,将之前学习过程中遗留的问题必须在假期解决.   本次课学习主要内容: 分支结构中的二分支结构.多分支结构和else-if语句 掌握字符型数据和逻辑运算 用switch语句实现多分支结构. 嵌套的if-else语句. 简单函数认识,并自定义函数. 复习总结选择结构中存在的问题 实验内容:(60分) 1. 输入一个正整数n,再输入n个数,统计其中偶数的个数. 2. 编写程序,输入一个数,如果输入1,输出"添加学生信息",如果输入…
大神们都在刷usaco,我也来水一水 1606: [Usaco2008 Dec]Hay For Sale 购买干草   裸背包 1607: [Usaco2008 Dec]Patting Heads 轻拍牛头 神转化,筛法 1609: [Usaco2008 Feb]Eating Together麻烦的聚餐  LIS 1610: [Usaco2008 Feb]Line连线游戏 排序 1611: [Usaco2008 Feb]Meteor Shower流星雨  BFS 1612: [Usaco2008…
最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [Usaco2004 Dec]Bad Cowtractors牛的报复  很明显是最大生成树了吧,跟最小生成树一样做就行了 = =(排序时按从大到小的顺序排) [Usaco2004 Dec]Cleaning Shifts安排值班  贪心,按开始时间从小到大排,然后对于已经安排的时间,取在此时间开始的最晚…
bzoj上的usaco题目还是很好的(我被虐的很惨. 有必要总结整理一下. 1592: [Usaco2008 Feb]Making the Grade 路面修整 一开始没有想到离散化.然后离散化之后就很好做了.F[I,j]表示第i个点,高度>=j或<=j,f[I,j]=min(f[i-1,j]+abs(b[j]-a[i]),f[I,j-1]) 1593: [Usaco2008 Feb]Hotel 旅馆 线段树 ★1594: [Usaco2008 Jan]猜数游戏 二分答案然后写线段树维护 15…