CodeForces 779C Dishonest Sellers】的更多相关文章

贪心. 如果这周便宜,那么肯定这周买.另外要求这周至少买到$k$个,那么肯定是需要额外购买差价小的. #include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include<vector> #include<cstdio> #include<cstring> #incl…
C. Dishonest Sellers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor kno…
[题目链接]:http://codeforces.com/contest/779/problem/C [题意] 有n个商品; 打折前买和打折后买的价格不一样; 且必须有至少k个商品在打折前买; 问你买走全部n个商品最少需要多少钱; [题解] /* 每件商品先选择打折前和打折后里面价格较低的; 然后把价格全部加起来(我好像神经病写了个排序); 然后看看你选了几个第一种商品; 少选了,就选一些在打折后买的商品加上差价在打折前买; 把差价升序排一下,选择大于等于0的加上差价就是答案了 if (a[i]…
按照b[i]-a[i],对物品从大到小排序,如果这个值大于零,肯定要立刻购买,倘若小于0了,但是没买够K个的话,也得立刻购买. #include<cstdio> #include<algorithm> using namespace std; struct Point { int x,y; }a[200010]; int n,K,ans; bool cmp(const Point &a,const Point &b) { return a.y-a.x>b.y-…
题意: Igor found out discounts in a shop and decided to buy n items. Discounts at the store will last for a week and Igor knows about each item that its price now is ai, and after a week of discounts its price will be bi. Not all of sellers are honest,…
目录 Codeforces #402 Codeforces #402 Codeforces 779A Pupils Redistribution 链接:http://codeforces.com/contest/779/problem/A 题意:有A组和B组,每组有n个人,A组里面每个人的分值为\(a_i\),B组里面每个人的分值为\(b_i\),\(1\le a_i ,b_i\le5\),至少双方要交换多少人才能使使A组里面每种分值的人要和B组里面一样多. 思路:如果两个在\(i\)这个分值上…
Codeforces Round #402 (Div. 2) A. Pupils Redistribution 模拟大法好.两个数列分别含有n个数x(1<=x<=5) .现在要求交换一些数使得两个数列含有某个数字的个数相同,求最少交换次数. int v1[N],v2[N]; int main() { int n; while(~scanf("%d",&n)) { int x; memset(v1,0,sizeof(v1)); memset(v2,0,sizeof(v…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
A. Pupils Redistribution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In hig…
2017.2.26 CF D2 402 这次状态还算能忍吧……一路不紧不慢切了前ABC(不紧不慢已经是在作死了),卡在D,然后跑去看E和F——卧槽怎么还有F,早知道前面做快点了…… F看了看,不会,弃 E看了看,不会,弃 D看了看,不会……没法再弃了.想了好久发现可以二分答案(浪费30min) 过了D以后去看F,发现果然还是不会(浪费20min) 之后看E,思路跑偏浪费20min+ 此时时间还剩大约20min,终于想到了E可能是正解的做法,开始拼手速,各种调试,终于调过了样例,而时间只剩10s了…