题目链接:http://codeforces.com/contest/767/problem/E


居然是一个瞎几把贪心(E比B水系列)

  考虑要每一次操作至少要用${\left \lfloor \frac{c[i]}{100} \right \rfloor}$张百元大钞,然后剩下的要不是用一张百元大钞收获一堆硬币并产生不高兴值,要么直接使用硬币买。我们可以把问题转换为强制每次操作都是用硬币买的,那么是不是就要从之前没有没有用过百元大钞的操作中改变若干个变成用了百元大钞的,然后收下这些硬币直到数量满足这次操作所需的。用一个堆来维护每次操作使用百元大钞会产生的不高兴值,使用一张百元大钞都相当于增加了100枚硬币。每次操作使用百元大钞会产生的不高兴值就是 ${w[i]*((100-c[i])~~mod~~100)}$ ,贪心即可。


 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
#define maxn 1001000
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,val[maxn],w[maxn],res,ans;
bool bj[maxn]; struct node
{
llg w,val,wz;
bool operator <(const node&a)const{
return a.val<val;
}
}; priority_queue<node>q; int main()
{
yyj("E");
cin>>n>>res;
for (llg i=;i<=n;i++) scanf("%lld",&val[i]);
for (llg i=;i<=n;i++) scanf("%lld",&w[i]);
for (llg i=;i<=n;i++)
{
node ne;
// ans1[i]=val[i]/100;
if (val[i]%==) continue;
ne.w=w[i]; ne.val=w[i]*(-val[i]%); ne.wz=i;
res-=val[i]%;
q.push(ne);
while (res<)
{
ne=q.top(); q.pop();
// ans2[ne.wz]=0;
res+=;
bj[ne.wz]=;
}
} for (llg i=;i<=n;i++)
{
if (bj[i])
{
ans+=(-val[i]%)*w[i];
}
}
cout<<ans<<endl;
for (llg i=;i<=n;i++)
{
if (bj[i])
{
printf("%lld 0\n",val[i]/+);
}
else printf("%lld %lld\n",val[i]/,val[i]%);
}
return ;
}

Codeforces 767E Change-free的更多相关文章

  1. 【codeforces 767E】Change-free

    [题目链接]:http://codeforces.com/problemset/problem/767/E [题意] 你有m个1元硬币和无限张100元纸币; 你在第i天,需要花费ci元; 同时在第i天 ...

  2. Change-free CodeForces - 767E (贪心)

    题目链接 大意:Arseny有m个1元硬币, 无限多100元钞票, 他要按顺序买n个东西, 第i天如果找零x个硬币, 他的不满值会加 w[i]*x, 求最少不满值. 若找零, 则硬币增加 100-ci ...

  3. codeforces C. New Year Ratings Change 解题报告

    题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...

  4. Mass Change Queries Codeforces - 911G

    https://codeforces.com/contest/911/problem/G 没想到线段树合并还能这么搞.. 对每个权值建一个线段树(动态开点),如果权值为k的线段树上第i位为1,那么表示 ...

  5. Codeforces Round #598 (Div. 3) A. Payment Without Change 水题

    A. Payment Without Change You have a coins of value n and b coins of value 1. You always pay in exac ...

  6. Codeforces.472F.Design Tutorial: Change the Goal(构造 线性基 高斯消元)

    题目链接 \(Description\) 给定两个长为\(n\)的数组\(x_i,y_i\).每次你可以选定\(i,j\),令\(x_i=x_i\ \mathbb{xor}\ x_j\)(\(i,j\ ...

  7. Mass Change Queries CodeForces - 911G (线段树合并)

    链接 大意: 给定序列, 每次操作将区间[l,r]中的x全改为y, 最后输出序列 权值范围比较小, 对每个权值开一颗线段树, 每次将x合并到y上即可 #include <iostream> ...

  8. [Codeforces 10E] Greedy Change

    Brief Introduction: 给你一些种类的硬币,用最少的硬币数表示X 求最小的使贪心算法错误的X Algorithm: 一道论文题,<A Polynomial-time Algori ...

  9. Codeforces Round #373 (Div. 2)

    A,B,C傻逼题,就不说了. E题: #include <iostream> #include <cstdio> #include <cstring> #inclu ...

随机推荐

  1. MaxiSYS Elite

    The Maxisys Elite is Autel UK’s top of the range diagnostic and analysis scanner with advanced J2534 ...

  2. How many zero's and how many digits ? UVA - 10061

    Given a decimal integer number you will have to find out how many trailing zeros will be there in it ...

  3. getopt_long_only

    st_i2c_parser.c中用到,遂学习一下: 参考:https://blog.csdn.net/pengrui18/article/details/8078813 https://blog.cs ...

  4. Java连接数据库 #04# Apache Commons DbUtils

    索引 通过一个简单的调用看整体结构 Examples 修改JAVA连接数据库#03#中的代码 DbUtils并非是什么ORM框架,只是对原始的JDBC进行了一些封装,以便我们少写一些重复代码.就“用” ...

  5. 9i时候的块

    Header (Common and Variable) The header contains general block information, such as the block addres ...

  6. 安装python3.7和PyCharm专业版

    安装python3.7 安装PyCharm专业版 1.下载地址http://www.jetbrains.com/pycharm/download/,选择windows下面的Professional,点 ...

  7. 谈论linux同组多用户操作问题

    同组多用户,最先起到什么作用这个我也是不明白的, 然后乱搞了一堆, 下面我做个笔记帮组日后分析. 一个用户组承载多个用户, 像这样 这是我原先的思路.然后就是chenglee用户和chenglee12 ...

  8. python --- 22 初始模块 random time collections functools

    一 .初始模块 1.从⼩到⼤的顺序: ⼀条代码 < 语句块 < 代码块(函数, 类) < 模块 2.引入模块的方式 ①   import   模块 ②   from   模块  im ...

  9. Maven本地仓库引入自定义/第三方的jar

    在cmd下输入如下: mvn install:install-file -Dfile=D:\ojdbc7.jar -DgroupId=com.tech4j.driver -DartifactId=or ...

  10. Python 实用技巧

    模块相关 导入模块时,可以通过模块的 __file__ 属性查看模块所在磁盘的路径位置,参考:关于Python包和模块的10个知识清单 Pip 安装Pip 方法一: sudo apt-get purg ...