Codeforces Round #280 (Div. 2) C

C51红外接收与发射控制及原理编码与解码 基于38khz的NEC协议红外发射简易电路图NEC协议产生红外光数据编码 0 1结合程序红外接收接收电路解码过程解码代码 红外发射 通过通过红外二极管发射红外光,三极管的状态来控制。 红外模块一般都是三个引脚,vcc,gnd,dat,通过控制dat口的来控制发射红外光。 简易电路图 将数据口连接到单片机的引脚为上,控制io口的电平状态,来控制三极管的导通状态,从而发射红外光。 NEC协议 NEC协议特点:8位地址和8位命令为提高可靠性,地址和命令都传输2次,脉冲间隔调制38kHz载波频率。 包含引导码, 阅读详情

题目:

C. Vanya and Exams
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th exam. To increase the grade for the i-th exam by 1 point, Vanya must write bi essays. He can raise the exam grade multiple times.

What is the minimum number of essays that Vanya needs to write to get scholarship?

Input

The first line contains three integers n, r, avg (1 ≤ n ≤ 105, 1 ≤ r ≤ 109, 1 ≤ avg ≤ min(r, 106)) — the number of exams, the maximum grade and the required grade point average, respectively.

Each of the following n lines contains space-separated integers ai and bi (1 ≤ ai ≤ r, 1 ≤ bi ≤ 106).

Output

In the first line print the minimum number of essays.

Sample test(s)
input
5 5 4
5 2
4 7
3 1
3 2
2 5
output
4
input
2 5 4
5 2
5 2
output
0
Note

In the first sample Vanya can write 2 essays for the 3rd exam to raise his grade by 2 points and 2 essays for the 4th exam to raise his grade by 1 point.

In the second sample, Vanya doesn't need to write any essays as his general point average already is above average.


分析:贪心,优先bi最小的。然后注意下n*avg这里会爆LL就好了。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <set>
#include <limits>
#include <map>

using namespace std;

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define F(i, n) for(int (i)=0;(i)<(n);++(i))
#define REP(i, s, t) for(int (i)=(s);(i)<=(t);++(i))
#define UREP(i, s, t) for(int (i)=(s);(i)>=(t);--(i))
#define REPOK(i, s, t, o) for(int (i)=(s);(i)<=(t) && (o);++(i))
#define MEM0(addr) memset((addr), 0, sizeof((addr)))

#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398

#define MAXN 100000
#define MAXM 10000
#define MOD 1000000007

typedef long long LL;

const double maxdouble = numeric_limits<double>::max();
const double eps = 1e-10;
const int INF = 0x7FFFFFFF;


typedef long long LL;
LL n, r, avg;
struct node
{
    LL a, b;
};

int cmp(node x,node y)
{
    return x.b<y.b;
}

int main()
{
    cin >> n >> r >> avg;


    vector<node> v;

    LL tma, tmb, sum = 0;
    REP(i, 0, n-1)
    {
        cin >> tma >> tmb;
        sum += tma;
        v.push_back((node)
        {
            tma, tmb
        });
    }

    sort(v.begin(), v.end(), cmp);

    LL rest = avg*n-sum;

    if (rest <= 0)
    {
        cout << 0;
        return 0;
    }
    LL ans = 0;
    for (int i=0; i<n && rest; ++i)
    {
        LL can = r - v[i].a;
        if(rest >= can)
        {
            ans += v[i].b * can;
            rest -= can;
        }
        else
        {
            ans += v[i].b * rest;
            rest = 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}



MounRiver Studio实战:像管理个人项目一样整理沁恒MCU的EVT例程(附文件结构图) 本文详细介绍了如何使用MounRiver Studio重构沁恒MCU的EVT例程,实现工程化管理。通过分析官方EVT设计的局限性,提出标准化的目录结构和迁移步骤,帮助开发者提升代码可维护性和团队协作效率。文章还提供了MounRiver Studio的关键配置参数和常见问题排查指南,适用于沁恒MCU开发者。 阅读详情

相关推荐

ADS学习笔记 2. 低噪声放大器设计

ADS学习笔记 2. 低噪声放大器设计。设计了一个中心频率433MHz,增益18.206dB,NF=0.134dB,S11带宽较好的低噪声放大器

u014087103的博客 9507

Codeforces Round #280 (Div. 2) 解题报告 A.B.C.D.E.

不知道到底是我的水平提高了还是CF的题目变水了。。。。。。 A - Vanya and Cubes 水题。。暴力枚举就可以。。 代码如下: #include #include #include #include #include #include #include #include #include #include #include using namespa

scf0920 1160

C语言—for循环打印矩形,正三角形,倒三角形,九九乘法,等腰三角形,倒着的等腰三角形(简易版代码)(重点考察for循环嵌套)

本章节教大家如何利用for循环打印正三角形,倒三角形,九九乘法表及等腰三角形(简易版代码)说明:1、循环语句的循环体内又包含另一个完整的循环结构,称为循环结构的嵌套。内嵌的循环语句中还可以再嵌套循环结构,这样就形成多重循环结构的嵌套。2、for 语句、while 语句和 do-while 语句都允许嵌套。三种循环语句可以相互嵌套。3、内层的循环语句必须完全被包含在外层的循环体中,不能发生交叉。

m0_63501145的博客 1695

Codeforces Round #280 (Div. 2) c

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34247299的博客 109

半桥LLC谐振变换器及同步整流MATLAB仿真(一)

LLC工作原理详细解析,工作过程详细拆解

qq_55203246的博客 3万+

Java服务端实现Google Pay支付功能

全网最全代码、最清晰服务端处理Google Pay,最清晰讲解Google Pay集成逻辑。

jack2350536098的博客 1万+

Codeforces Round #280 (Div. 2)A B C

A - Vanya and Cubes: #include #include #include using namespace std; typedef __int64 ll; const int N = 10005; ll a[N]; int main() { a[0] = 0; for( ll i = 1; i <= 10000; i++ ) {

uuuuuu 515

开源代码分享(29)-基于拉丁超立方抽样的风光场景生成和削减

作为分层抽样方法的一 种,拉丁超立方抽样具有良好的抽样精度和效率[14]。本文使用多场景方法来描述可再生能源(风电、光伏)的不确定性。以风电功率为例,首先假定风电功率服从正态分布 N(μ, δ 2 ),μ 为预测值的期望值,δ 为其波动的百分比。接着,采用拉丁超立方抽样[21]生成大量服从概率分布约束的风电出力场景,并采用考虑 Kantorovich 距离[22]的场景削减技术处理该场景,进行场景削减。最后,导出具有相应概率的削减之后的场景。

配电网和matlab的博客 921

Codeforces Round #280 (Div. 2) A B C

http://codeforces.com/contest/492 A 水题 A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

mfcheer 635

基于STM32+RFID设计的宿舍检修管理系统

设计一个上位机,用来管理查看维修检修信息,当维修寝室的设备或者检修完成时,通过STM32上的RC522刷一下这个寝室的IC卡,识别这是哪个寝室,识别成功后在软件上弹出一个对话框,填写本次维修或者检修的事件,填写完毕点击提交即可。...

2555

Keras神经网络可视化模块keras.utils.visualize_util的安装配置方法

本文介绍了如何安装和配置keras.utils.visualize_util模块,并提供了一个简单的示例演示如何使用该模块来可视化神经网络的结构。在上述代码中,我们首先定义了一个简单的神经网络模型,该模型具有一个输入层、一个隐藏层和一个输出层,其中隐藏层具有512个神经元,输出层具有10个神经元。运行上述代码后,我们将在当前工作目录下找到一个名为model.png的文件,它显示了神经网络的结构图。这种方式有效地展示了整个过程,让我们能够更好地理解神经网络的结构,方便对其进行改进和调试。

. 890

Codeforces Round #280 (Div. 2) A,B,C,D

A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya got n cubes. He decided to build a pyramid fr

mystery_guest的博客 560

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Codeforces Round #280 (Div. 2 A,B,C,D,E)

改了时区之后打cf更辛苦了啊。。。昨天没做,今天补了一下啊。 A. Vanya and Cubes 每次加的数规律性很明显就是:(i+1)*i/2。暴力枚举i就可以得到答案。 #include #include #include #include #include #include #include #include #include #include #include

I am a slow walker, but I never walk backwards! 1156

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Codeforces Round #280 (Div. 2) 解题报告(A B C D E)

A. Vanya and Cubes         思路:累加计算叠到每个高度至少需要多少方块,然后找最后一个满足的即可。 #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define INF 1

A Cube Master 838

Codeforces Round #280 (Div. 2) A , B , C

A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya gotncubes. He decided to build a pyramid ...

weixin_30478923的博客 95

Codeforces Round #280 (Div. 2) C. Vanya and Exams 贪心

C. Vanya and Exams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/problem/C Description Vanya wants to pass n exams and get the academic scholarship. He will get ...

weixin_33970449的博客 124

Codeforces Round #280 (Div. 2) C. Vanya and Exams

Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has pass

Halo 910

Codeforces Round #280 (Div. 2)C. Vanya and Exams(贪心)

题目链接 题意:告诉你某人有n们课程,每一门的课程有分数上限r,以达到及平均分avg,才能拿奖学金,然后给出每门课当前的得分ai,以及如果你写bi篇文章的话,会使你的该们课程的分数提升一点,。 解法:贪心,按照bi小的开始贪心的选择。 #define CF #ifndef CF #include<cstdio> #include<algorithm> #include<cstring> #inc

qwesde 449

Codeforces Round #280 (Div. 2)_C. Vanya and Exams

C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n exams and get the a

Tovi的博客 615

Codeforces Round #280 (Div. 2)---C. Vanya and Exams (贪心)

Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vanya wants to pass n exams and get the ac

sxk 1372

Codeforces #280 (Div.2 A~E)

Codeforces Round #280 (Div. 2) A. Vanya and Cubes 题意: Vanya要堆金字塔,第1层要1个方块,第2层要1+2个,第3层要1+2+3个,以此类推。现在Vanya有n个方块,求能堆的金字塔的最大高度。 题解: 设金字塔高度为h,则需要的积木数为\sum_{i = 1} ^ {h} {\sum_{j = 1} ^ {i} {j}

skywalkert's space 1251

【codeforces】Codeforces Round #280 (Div. 2) 水题专场

传送门:【codeforces】Codeforces Round #280 (Div. 2) 492A. Vanya and Cubes 找到最大的i使得1+2+3+……+i小于等于n,并且输出i。 #include #include #include using namespace std ; typedef long long LL ; #define rep( i ,

poursoul 793

Codeforces Round #280 (Div. 2)

30min的时候提醒电量剩余10%,35min的时候水过B题,关电脑睡觉 updata1:早上6:45开始补题,15min写完C,调到8:12,怎么搞的,思路很清楚,写起来超乱。写完了CF也挂了... 两点原因:重载'

CHEATBEATER 757
上一篇: Codeforces Round #280 (Div. 2) B
下一篇: Codeforces Round #280 (Div. 2) D
Notdeep__acm
博客等级 码龄12年 20粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值