【题解】CF161B Discounts】的更多相关文章

目录 题目 思路 \(Code\) 题目 CF161B Discounts 思路 贪心.很显然对于一个板凳(价格为c)所能使我们最多少花费\(\frac{c}{2}\)的金钱. 原因如下: 如果你将一件价格比该板凳大的商品与板凳放在一起没有贡献. 如果你将一件价格比该板凳小的商品与板凳放在一起贡献减小. 贪心策略:将板凳中价格前\(k-1\)大的单独放一辆购物车,板凳不够就用商品即可. \(Code\) #include<iostream> #include<cstring> #i…
目录 CF140C New Year Snowmen CF161B Discounts P1842 奶牛玩杂技 CF140C New Year Snowmen #include <bits/stdc++.h> using namespace std; #define gc getchar() #define rep(i , x, y) for(int i = x;i <= y;++ i) #define sep(i , x, y) for(int i = x;i >= y;-- i…
传送门 Luogu 解题思路 贪心地想一想,我们肯定要让凳子去给价格越高的商品打半价,那么我们就先按照价格排序,但是要优先把凳子排在前面. 然后我们发现一条凳子肯定只能给价格小于等于它本身的物品打半价,所以我们就尽量把所有凳子单独放一个购物车,但是要注意判断一下凳子数量和购物车数量的关系,这里不啰嗦了. 细节注意事项 分类讨论的过程不能少,但要是想做到码量少就要细心一点 参考代码 #include <algorithm> #include <iostream> #include &…
Content 有一个长度为 \(n\) 的数组 \(a_1,a_2,a_3,...,a_n\).有 \(q\) 次询问,每次询问给定一个数 \(x\).对于每次询问,求出数组中去掉一个第 \(x\) 大的数字后数组内剩余的数字的总和. 数据范围:\(2\leqslant n\leqslant 3\times 10^5,1\leqslant a_i\leqslant 10^9,1\leqslant m<n,2\leqslant q_i\leqslant n\). Solution 预处理出所有数…
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须买q[i]个东西,然后他会送你{0,1,2}个物品,但是送的物品必须比你买的最便宜的物品还便宜,问你最少花多少钱,买完m个物品 题解 显然我选择q[i]最小的去买就好了 代码 #include<bits/stdc++.h> using namespace std; const int maxn =…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he know…
A.Regular bracket sequence A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting…
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我没看,看不懂. 基本思路:我不会. 参考代码:找Oyk老师和Czj老师去. B. The background of water problem 题目大意(大写加粗的水题):给定$N$个学生和他们$K$个科目的成绩$S_i$,再给出各科目$K_i$的权重顺序$Q_i$,求排名之后,拥有id为$X$的…
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <…
2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2561 Description 给定一个边带正权的连通无向图G=(V,E),其中N=|V|,M=|E|,N个点从1到N依次编号,给定三个正整数u,v,和L (u≠v),假设现在加入一条边权为L的边(u,v),那么需要删掉最少多少条…