【题目链接】: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. springboot实现拦截器

    你首先需要一个搭建好的springboot项目,具体怎么搭建我还没有相应的随笔可以交给你,可以自己上网上看一下,学习一下,之后我要是总结出来的话,这里面我会通知的 首先这个项目的目录结构是这样子的 首 ...

  2. SSH框架整合截图总结(三)

    联系人信息查询1 点击 联系人信息查询 超链接时候,到查询页面 (1)在查询页面中,选择客户,根据客户进行查询 下拉表框显示所有客户  可以根据所属的客户进行联系人查询  2 在查询页面中,输入值,提 ...

  3. [HTML 5] More about ARIA Relationships

  4. 使用Android Studo开发NDK之Gradle的配置(能debug C代码)

    配置: 用的版本号是AS1.5(也能够尝试更高版本号). Gradle地址是distributionUrl=https\://services.gradle.org/distributions/gra ...

  5. iOS 常见面试图总结2

    1.请简述storyboard和xib的差别? 一个project中.能够有多个xib文件,一个xib文件相应着一个视图类控制器,和多个视图. 然而.使用 storyboard时,一个project仅 ...

  6. USACO 2.2 Preface Numbering

    Preface Numbering A certain book's prefaces are numbered in upper case Roman numerals. Traditional R ...

  7. 如何版本化你的API?--转

    原文地址:http://www.infoq.com/cn/news/2017/09/How-versioning-API 如何版本化API需要考虑各种实际业务场景,但是一个完备的API应该是: 和客户 ...

  8. CSDN日报20170527 ——《人机大战,历史的见证》

    在网络层,互联网提供所有应用程序都要使用的两种类型的服务,尽管目前理解这些服务的细节并不重要,但在所有TCP/IP概述中,都不能忽略他们: 无连接分组交付服务(Connectionless Packe ...

  9. Unity 围绕X、Y、Z旋转图例

    绿色:绕X 红色:绕Y 蓝色:绕Z PS:这是右手坐标系,Unity为左手坐标系 不知道啥叫左手右手?参见我的另一篇文章http://www.cnblogs.com/36bian/p/7571727. ...

  10. Python多线程原理与实现

    Date: 2019-06-04 Author: Sun Python多线程原理与实战 目的: (1)了解python线程执行原理 (2)掌握多线程编程与线程同步 (3)了解线程池的使用 1 线程基本 ...