zoj 3745 Salary Increasing
来源:互联网 发布:怎么加盟农村淘宝 编辑:程序博客网 时间:2024/05/05 22:21
题意:某老板要给员工涨薪,每次给工资在[l,r]范围的人涨c单位工资,问最后老板要付多少钱。
思路:这题其实是到水题,放上来的原因是提醒自己认真看题…… 题里有个条件:ri <li+1 看到这个条件基本就做出来了,从这个条件发现区间是不重叠的,因此,直接暴力就可以了,用一个数组num[i]记录工资为i的员工的人数,每次涨薪操作后修改人数就行了。。。
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<map>#include<queue>#include<set>#include<stack>#include<cmath>#include<vector>#define inf 0x3f3f3f3f#define Inf 0x3FFFFFFFFFFFFFFFLL#define eps 1e-9#define pi acos(-1.0)using namespace std;typedef long long ll;const int maxn=100000+10;int num[maxn];int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n,q; while(~scanf("%d%d",&n,&q)) { int tmp; ll sum=0; memset(num,0,sizeof(num)); for(int i=0;i<n;++i) { scanf("%d",&tmp); num[tmp]++; sum+=tmp; } int l,r,c; while(q--) { scanf("%d%d%d",&l,&r,&c); //if(l>r) swap(l,r); for(int i=r;i>=l;--i) { sum+=(ll)c*num[i]; if(i+c<maxn) num[i+c]+=num[i]; num[i]=0; } } printf("%lld\n",sum); } return 0;}
0 0
- ZOJ 3745 Salary Increasing
- zoj 3745 Salary Increasing
- zoj 3745 Salary Increasing 暴力
- zoj 3745 Salary Increasing 哈希
- zoj 1499 Increasing Sequences
- salary
- salary
- salary
- Increasing Sequences-ZOJ 1499 POJ 1039
- Zoj 2432 Greatest Common Increasing Subsequence(DP)
- zoj 2432 && hdoj 1423 Greatest Common Increasing Subsequence 【打印LCIS】
- salary图
- salary 图
- salary--类
- database :salary
- Salary Inequity
- zoj 2432 Greatest Common Increasing Subsequence(最长公共上升子序列)
- POJ 题目1239 ||ZOJ 题目 1499 Increasing Sequences(正反两次DP)
- 什么是UML
- fedora 20 源码编译安装 mysql-5.6.15
- Linked List Cycle 链表是否有环
- (十)Struts2中XML验证
- 雷風正位用政
- zoj 3745 Salary Increasing
- 桎梏的开始03
- Linked List Cycle II 链表环的入口
- Tomcat Context docBase指定的目录层次不能超过2层
- primary key与unique的区别
- 数据结构实验之链表七:单链表中重复元素的删除
- table鼠标移动拖动点击排序
- C++ code completion
- 搬寝室