Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心
来源:互联网 发布:安卓手机数据恢复工具 编辑:程序博客网 时间:2024/05/21 16:55
参考http://www.cnblogs.com/qscqesze/p/5925893.html
题意
给你n个数,你可以操作k次,每次使得一个数增加x或者减小x
你要使得最后所有数的乘积最小,问你最后这个序列长什么样子。
#define rson md+1,rr,rsset<pii>se;LL a[N];int main(){ int n,k,x; sf("%d%d%d",&n,&k,&x); int sig=0; rep(i,1,n){ cin>>a[i]; if(a[i]<0)sig^=1; se.insert(MP(abs(a[i]),i)); } for(int i=1;i<=k;++i){ int pos=se.begin()->second; se.erase(se.begin()); if(a[pos]<0)sig^=1; if(sig)a[pos]+=x; else a[pos]-=x; if(a[pos]<0)sig^=1; se.insert(MP(abs(a[pos]),pos)); } for(int i=1;i<=n;++i){ cout<<a[i]<<' '; }puts("");}
阅读全文
0 0
- Codeforces Round #374 (Div. 2)D. Maxim and Array(贪心)
- Codeforces Round 374 (Div 2)D Maxim and Array 【贪心】
- Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心
- Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心
- Codeforces Round #374 (Div. 2) D - Maxim and Array
- Codeforces Round #374 (Div. 2) D. Maxim and Array
- Codeforces Round #374 (Div. 2) D. Maxim and Array
- Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心+ 最小堆
- Codeforces Round #374 (Div. 2) D. Maxim and Array —— 贪心
- 【Codeforces Round 374 (Div 2)D】【贪心】 Maxim and Array n个数做K次±X使得乘积尽可能小
- Codeforces 721D Maxim and Array[贪心]
- codeforces 721D Maxim and Array(贪心)
- codeforces 721D. Maxim and Array(贪心)
- CodeForces 721D. Maxim and Array(贪心,思维题)
- Codeforces712 D. Maxim and Array (贪心)
- 721D Maxim and Array codeforces(模拟)
- 【24.17%】【codeforces 721D】Maxim and Array
- Codeforces Round #331 (Div. 2) B. Wilbur and Array (贪心)
- hadoop集群搭建
- 为什么匿名内部类和局部内部类只能访问final变量
- 传纸条
- 第3篇 快速排序
- 基于scp协议向linux发送文件
- Codeforces Round #374 (Div. 2) D. Maxim and Array 贪心
- 670. Maximum Swap
- 最小二乘法及其拟合
- Spring学习之——控制反转(IoC)与依赖注入(DI)
- git如何删除已经 add 的文件 (如何撤销已放入缓存区文件的修改)
- 【Android】【TP】TP开发常见问题&分析
- JavaScript中七种函数调用方式及对应 this 的含义
- POJ 3258 River Hopscotch 二分
- centos安装tomcat