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. mysqli字符编码

    mysqli 字符编码: 汉字编码: 1.gbk 最久的编码格式,不能写繁体: 2.国内的gb2312: 3.国际的标准:utf-8; 查看数据库的字符编码: show variables like ...

  2. 高校手机签到系统——第一部分Authority权限系统(上)

    序:今天开始写一个算是我第一个系列的文章——高校手机签到系统.本系统结合我们学校自身的一些特点编写.这是我的毕业设计项目,写在这里算是给最后论文的时候一些点滴的记录.另外也想通过这个系列的文章找到一份 ...

  3. C#与Excel的交互示例

    //这里加添加一个Excel对象的包装器.就是添加一个引用 using System; using System.Drawing; using System.Collections; using Sy ...

  4. chrome视频播放加速

    安装video speed controller, 下载源码https://github.com/igrigorik/videospeed,解压 在chrome输入chrome://extention ...

  5. JavaScript: DOM Docunment

    Meaning: In browser , we exchange data using JavaScript code with user. We should know that most of ...

  6. PostgreSQL使用笔记

    下载并安装 注意安装图形界面 pgAdmin 需要输入缺省用户 postgres 的密码 在 Windows 下安装之后注意把 bin文件夹加到 Path 环境变量中. 重置密码 使用管理员权限打开 ...

  7. mac下安装cnpm淘宝镜像

    cnpm:官网 (事先已经安装了node,有npm)查看官网,提示安装需运行命令:npm install -g cnpm --registry=https://registry.npm.taobao. ...

  8. SSM商城项目(五)

    1.   学习计划 1.前台系统搭建 2.商城首页展示 3.Cms系统的实现 a)         内容分类管理 b)         内容管理 4.前台内容动态展示 2.   商城首页展示 2.1. ...

  9. windows上安装Maven与Gradle

    (一)安装Maven 1.百度maven,进入官网http://maven.apache.org/download.cgi,选择Download,在选择相应的压缩包apache-maven-3.6.0 ...

  10. spring proxy-target-class

    <tx:annotation-driven transaction-manager="transactionManager"                          ...