【题目链接】:http://codeforces.com/contest/810/problem/B

【题意】



每天有ki件物品,你知道每天能卖掉li件;

然后让你选f天;

这f天,可以将ki乘上2;

每天结束之后物品清空;

问你最多能卖多少件物品;

【题解】



先算出来不用f天的乘2效果;

卖出的物品数目;

然后考虑;

乘2之后,能够多卖的物品数量;

排个序,逆序排,然后取前f个就好;

累加答案;



【Number Of WA】



0



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0),cin.tie(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100; int n,f;
LL k[N],l[N];
LL b[N];
LL ans = 0; int main()
{
//Open();
Close();//scanf,puts,printf not use
//init??????
cin >> n >> f;
rep1(i,1,n)
cin >> k[i] >> l[i];
rep1(i,1,n)
ans+=min(k[i],l[i]);
rep1(i,1,n)
{
if (k[i]<l[i])
{
l[i]-=k[i];
b[i] = min(k[i],l[i]);
}
else
{//k[i]>=l[i];
b[i] = 0;
}
}
sort(b+1,b+1+n);
reverse(b+1,b+1+n);
rep1(i,1,f)
ans+=b[i];
cout << ans << endl;
return 0;
}

【codeforces 810B】Summer sell-off的更多相关文章

  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. 【76.83%】【codeforces 554A】Kyoya and Photobooks

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

  3. 【codeforces 707E】Garlands

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

  4. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  5. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  6. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  7. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  8. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  9. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

随机推荐

  1. 00073_Math类

    1.Math类概述 (1)Math 类是包含用于执行基本数学运算的方法的数学工具类,如初等指数.对数.平方根和三角函数: (2)类似这样的工具类 ,其所有方法均为静态方法,并且一般不会创建对象.如Sy ...

  2. DOM中元素节点,属性节点,文本节点的理解

    节点信息 每个节点都拥有包含着关于节点某些信息的属性.这些属性是: nodeName(节点名称) nodeValue(节点值) nodeType(节点类型) nodeType nodeType 属性可 ...

  3. BA-siemens-desigo_cc安装

    1.首先安装NT3.5和NT4.0软件 2.按照以下网址的教程配置好IIS和WEBDAV环境:http://www.cnblogs.com/xiongzai/p/4126493.html 文章写的真不 ...

  4. [HTML5] Text Alternatives

    Most of times, we need 'alt' to the images, so it can tell the screen reader what is this image abou ...

  5. 使用Android design support library在Eclipse和Android Studio

    背景:为了在低版本号下使用Android 5.0的一些新特新 Eclipse篇: 1.将Android Manager中的Android support library升级到最新,我的为22.2.1' ...

  6. codeforces Towers 题解

    Little Vasya has received a young builder's kit. The kit consists of several wooden bars, the length ...

  7. Highcharts数据表示(2)

    Highcharts数据表示(2) 数据节点是图表中最小的元素.每一个数据节点都是一个数据单元. 它确定了图表中一个图形元素的各种信息.一个数据节点通常包含下面三类信息: 1.坐标位置信息 因为Hig ...

  8. apiCloud中的数据库操作mcm-js-sdk的使用

    1.引入js <!-- 引入mcm-js-sdk Begin --> <script type="text/javascript" src="../pl ...

  9. 《ServerLess 给前端带来了什么》笔记

    1. Serverless 是什么 Serverless “无服务器架构”,即大量依赖第三方服务(也叫做后端即服务,即“BaaS”)或暂存容器中运行的自定义代码(函数即服务,即“FaaS”)的应用程序 ...

  10. Linux目录结构(一)

    linux文件系统的最顶端是/,称为linux的root,所有的目录.文件.设备都在/之下. 文件类型 linux有四种基本文件系统类型:普通文件.目录文件.连续文件和特殊文件.可以用file命令来识 ...