https://www.luogu.org/problemnew/show/AT2442

 #include <bits/stdc++.h>
#define read read()
#define up(i,l,r) for(register int i = (l);i <= (r);i++)
#define down(i,l,r) for(register int i = (l);i >= (r);i--)
#define traversal_vedge(i) for(register int i = head[u]; i ;i = e[i].nxt)
#define ll long long
using namespace std;
int read
{
int x = , f = ; char ch = getchar();
while(ch < || ch > ) {if(ch == '-')f = -; ch = getchar();}
while(ch >= && ch <=) {x = * x + ch - ;ch = getchar();}
return x * f;
}
const int N = 2e5+;
ll n,q,S,T,b[N],ans; inline ll get(ll x)
{
return x > ? (-x*S) : (-x*T);
} int main()
{
freopen("input.txt","r",stdin);
n = read; q = read; S = read; T = read;
ll last = read;
up(i,,n)
{
ll x = read;
b[i] = x - last;
last = x;
ans += get(b[i]);
}
//ans代表b[i](1~n)遍历后的答案;
while(q--)
{
int l = read, r = read, x = read;
ans -= get(b[l]);// b[l]改变,先减后加;
b[l] += x;
ans += get(b[l]);
if(r < n)
{
ans -= get(b[r+]);//debug -= -> +=
b[r+] -= x;
ans += get(b[r+]);//degug += -> -=
}
printf("%lld\n",ans);
}
return ;
}

差分模版题(需理解才明白)AT2442 フェーン現象 (Foehn Phenomena)的更多相关文章

  1. AT2442 フェーン現象 (Foehn Phenomena)

    题目地址 原题地址 题解 其实就是一个区间加,单点查询的问题 当然可以线段树/树状数组做,但是这两个做法要分类讨论所以代码会比较多 我们考虑一种更简便的做法 差分! 因为温度只和海拔差有关,这相当于题 ...

  2. [noip模拟20170921]模版题

      今天考的是一套很基础的模版题,但是我这种蒟蒻竟然还是没有AK,不得不说,蒟蒻和大佬的差别不是一点点啊 1.暴走的猴子(walk.pas/c/cpp) [题目描述] 从前有一个森林,森林里生活着一群 ...

  3. HDU 2222 Keywords Search(AC自动机模版题)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  4. PAT (Top Level) Practise 1008 Airline Routes(Tarjan模版题)

    1008. Airline Routes (35) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue Given a ...

  5. poj 1986 Distance Queries 带权lca 模版题

    Distance Queries   Description Farmer John's cows refused to run in his marathon since he chose a pa ...

  6. 由一道CTF pwn题深入理解libc2.26中的tcache机制

    本文首发安全客:https://www.anquanke.com/post/id/104760 在刚结束的HITB-XCTF有一道pwn题gundam使用了2.26版本的libc.因为2.26版本中加 ...

  7. hdu2586 How far away ?(lca模版题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 题意:给出一棵树还有两个点然后求这两个点的最短距离. 题解:val[a]+val[b]-2*va ...

  8. lct 模版题 bzoj 2002 2049

    很早就有人给我推荐的模版题,然后我最近才刷的(' '    ) 昨天的tree 不知道比他们高到哪里去了,我和他谈笑风生啊! bzoj 2002 弹飞绵羊 重点:这道题的cut和link 由于这道题链 ...

  9. 【poj 1962】Corporative Network(图论--带权并查集 模版题)

    P.S.我不想看英文原题的,但是看网上题解的题意看得我 炒鸡辛苦&一脸懵 +_+,打这模版题的代码也纠结至极了......不得已只能自己翻译了QwQ . 题意:有一个公司有N个企业,分成几个网 ...

随机推荐

  1. SSH Secure Shell Client中文乱码的解决方法

    http://www.cnblogs.com/52linux/archive/2012/03/24/2415082.html 方案一:修改linux服务器的环境变量 使用linux,在用户根目录下有一 ...

  2. 用kettle从mysql中使用存储过程读取数据写入到sqlserver数据库

    1.mysql存储过程,可以实现动态表读取,满足较为复杂的业务逻辑 DROP PROCEDURE if exists p_get_car_trace; delimiter // CREATE PROC ...

  3. ADB server didn't ACK failed to start daemon 5037

    错误信息: C:\Users\lizy>adb devices adb devicesadb server is out of date.  killing... ADB server didn ...

  4. XAMPP 虚拟主机配置,实现多域名访问本地项目

    XAMPP 虚拟主机配置,实现多域名访问本地项目 1.首先你既然要配置多个虚拟主机,那你肯定需要多个站点的目录文件.你可以在e盘创建 www文件夹,然后在该文件件中新建两个站点目录,假设test.co ...

  5. 如何让大小一定的span能够包含“容不下”的内容

    overflow: hidden; text-overflow: ellipsis; width: 70px;(长度随意) 给span加上面的代码

  6. tomcat advanced (RUNNING)

    1. 1. tomcat

  7. Unable to complete the scan for annotations for web application [/wrs] due to a StackOverflowError. Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies.

    tomcat启动报错:Jul 20, 2018 11:48:37 AM org.apache.catalina.core.ContainerBase addChildInternalSEVERE: C ...

  8. 《算法导论》——计数排序Counting Sort

    今天贴出的算法是计数排序Counting Sort.在经过一番挣扎之前,我很纠结,今天这个算法在一些scenarios,并不是最优的算法.最坏情况和最好情况下,时间复杂度差距很大. 代码Countin ...

  9. HTML - input(转)

    自: http://www.runoob.com 标签定义及使用说明 <input> 标签规定了用户可以在其中输入数据的输入字段. <input> 元素在 <form&g ...

  10. 更改mysql 和jinkins目录

    更改MySQL数据目录 1.修改my.cnf,注销原datadir,增加新的数据目录 #datadir=/var/lib/mysqldatadir=/mysql-data/mysql 2.修改启动脚本 ...