Codeforces 767E Change-free
题目链接: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的更多相关文章
- 【codeforces 767E】Change-free
[题目链接]:http://codeforces.com/problemset/problem/767/E [题意] 你有m个1元硬币和无限张100元纸币; 你在第i天,需要花费ci元; 同时在第i天 ...
- Change-free CodeForces - 767E (贪心)
题目链接 大意:Arseny有m个1元硬币, 无限多100元钞票, 他要按顺序买n个东西, 第i天如果找零x个硬币, 他的不满值会加 w[i]*x, 求最少不满值. 若找零, 则硬币增加 100-ci ...
- codeforces C. New Year Ratings Change 解题报告
题目链接:http://codeforces.com/problemset/problem/379/C 题目意思:有n个users,每个user都有自己想升的rating.要解决的问题是给予每个人不同 ...
- Mass Change Queries Codeforces - 911G
https://codeforces.com/contest/911/problem/G 没想到线段树合并还能这么搞.. 对每个权值建一个线段树(动态开点),如果权值为k的线段树上第i位为1,那么表示 ...
- 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 ...
- 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\ ...
- Mass Change Queries CodeForces - 911G (线段树合并)
链接 大意: 给定序列, 每次操作将区间[l,r]中的x全改为y, 最后输出序列 权值范围比较小, 对每个权值开一颗线段树, 每次将x合并到y上即可 #include <iostream> ...
- [Codeforces 10E] Greedy Change
Brief Introduction: 给你一些种类的硬币,用最少的硬币数表示X 求最小的使贪心算法错误的X Algorithm: 一道论文题,<A Polynomial-time Algori ...
- Codeforces Round #373 (Div. 2)
A,B,C傻逼题,就不说了. E题: #include <iostream> #include <cstdio> #include <cstring> #inclu ...
随机推荐
- [转载]css3的一个控制背景的属性,background-size可以缩放大小啦
background-size需要两个值,它的类型可以是像素(px).百分比(%)或是auto,还可以是cover和contain.第一个值为背景图的width,另外一个值用于指定背景图上的heigh ...
- How to use CAR FANS C800 Diagnostic Scan Tool to do diagnosis operation
How to use Heavy Duty Diagnostic CAR FANS C800 Diagnostic Scan Tool to do diagnosis operation Here i ...
- Java学习路线:Java中的位移运算符介绍
学习java本来就是一件日积月累的事情,或许你通过自学能掌握一些皮毛技术,学到java的一些基本大面,但想要做到精通,还是需要自己技术的日积月累和工作经验的不断积累. 今天给大家分享的技术知识是:ja ...
- 使用json对象要注意的地方
本人是初学渣渣,使用json过程中遇到常见的问题,总结如下: 1--json对象内部不要有注释,虽然不报错,但是会使得渲染界面失败: 2--json对象是没有length属性的,若想获取到这个leng ...
- hibernate文档头的不同版本
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "h ...
- 控制层和ajax用法的详解
商城项目第二天复习的内容 package cn.tedu.store.entity; public class ResponseResult<T> { public static fina ...
- 使ipconfig命令结果更整洁
在windows下,使用ipconfig命令会出来很多内容,很多事ipv6隧道适配器的内容.而现在大部分人都还用不到ipv6,因此我们可以输入以下命令关闭ipv6隧道适配器,使命令结果更整洁. net ...
- c++ kafka 客户端rdkafka报Receive failed: Disconnected问题原因以及解决方法
%3|1538976114.812|FAIL|rdkafka#producer-1| [thrd:kafka-server:9092/bootstrap]: kafka-server:9092/0: ...
- unknown variable 'log_bin_basename'
今天在处理一问题时,在my.cnf中设置了log_bin_basename=/DATA/log-bin,在启动时报unknown variable 'log_bin_basename' 经查mysql ...
- 百度uid-generator源码
https://github.com/baidu/uid-generator snowflake算法 uid-generator是基于Twitter开源的snowflake算法实现的. snowfla ...