给定一个数列 \(a= { a_1,a_2,...,a_n }\) 以及 \(m\) 次操作,\(q\) 次查询。

其中第 \(i\) 次操作如同:\(l_i, r_i, d_i\),意指区间 \([ l_i, r_i]\) 中每个元素加上 \(d_i\)。

其中第 \(i\) 次查询如同:\(x_i, y_i\),意指需要执行第 \(x_i,x_i+1,...y_i\) 次操作。

现在问你,执行完所有查询后的序列 \(a\) 是怎么样的。

Input

第 \(1\) 行 \(n,m,k\);

第 \(2\) 行 \(a_1,a_2,...,a_n\);

接下来 \(m\) 行,每行三个整数 \(l_i,r_i,d_i\);

接下来 \(k\) 行,每行三个整数 \(x_i,y_i\);

数据范围:\(1≤n,m,k≤10^5, 1≤l_i≤r_i≤n, 0≤a_i,d_i≤10^5, 1≤x_i≤y_i≤m\)。

Output

单行打印 \(a_1, a_2, ..., a_n\)。用空格分隔打印的数字。

Sample Input 1

3 3 3
1 2 3
1 2 1
1 3 2
2 3 4
1 2
1 3
2 3

Sample Output 1

9 18 17

分析

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+10,INF=0x3f3f3f3f;
LL n,m,k,a[N],l[N],r[N],d[N],res=0;
LL b[N],c[N]; //#define local
int main(){
#ifdef local
freopen("data.in", "r", stdin);
// freopen("data.out", "w", stdout);
#endif cin>>n>>m>>k;
for(int i=1; i<=n; i++) cin>>a[i];
for(int i=1; i<=m; i++) cin>>l[i]>>r[i]>>d[i];
int x,y;
while(k--){
cin>>x>>y; b[x]++, b[y+1]--;
}
for(int i=1; i<=m; i++) b[i]+=b[i-1];
for(int i=1; i<=m; i++){
c[l[i]] += d[i]*b[i];
c[r[i]+1] -= d[i]*b[i];
}
for(int i=1; i<=n; i++) c[i]+=c[i-1], a[i]+=c[i];
for(int i=1; i<=n; i++) cout<<a[i]<<" \n"[i==n];
return 0;
}

最新文章

  1. 使用视 meta 标签来控制手机浏览器布局
  2. Google 地图 API V3 之 叠加层
  3. CentOS7下zip解压和unzip压缩文件
  4. ORACLE AWR报告生成过程出现多个实例记录分析
  5. 127.0.0.1、0.0.0.0和本机IP地址的区别和使用
  6. 【poj1017】 Packets
  7. LeetCode344:Reverse String@Python
  8. ubuntu 设置静态ip
  9. C#性能优化的一些技巧
  10. 指向函数的指针 分类: C/C++ 2015-07-13 11:03 14人阅读 评论(0) 收藏
  11. code testing
  12. Microsoft.Practices.Unity 给不同的对象注入不同的Logger
  13. (转)在Eclipse中使用JUnit4进行单元测试
  14. zf-关于注册码过期
  15. &lt;经验杂谈&gt;Mysql中字符串处理的几种处理方法concat、concat_ws、group_concat
  16. (10)Microsoft office Word 2013版本操作入门_word表格
  17. mysql文件
  18. scrapy中css选择器初识
  19. POJ2516 Minimum Cost【最小费用最大流】
  20. 网关绑定命令,解决arp攻击

热门文章

  1. oracle 2个数组列,剔除数组重复的数据。
  2. iOS ProtocolBuffer使用介绍
  3. 关于head中代码被挤到body中的问题
  4. 菜狗记录pycharm使用问题
  5. Fiddler 抓包转成*.har文件在httprunner执行
  6. GPS网络授时仪(网络授时服务器)成功投运攀枝花市中西医结合医院
  7. Qt 中文编译错误和运行显示乱码
  8. webpack 5 配置babel-loader babel7
  9. 关于idea2021.1版本的左边不显示bpmn Editor的问题
  10. transform2d转换、transition过渡、animation动画效果、@keyframes定义动画关键帧