题意翻译

题目简述

你知道N+1N+1个地点的海拔A_iAi​,编号为0 \dots N0…N,有风从00吹向NN,想让你求出地点NN的风的温度.

保证A_0=0A0​=0

规则:

  • 如果A_i=A_{i+1}Ai​=Ai+1​风的温度不变.
  • 如果A_i>A_{i+1}Ai​>Ai+1​由于海拔降低,风的温度会上升(A_i-A_{i+1})\times T(Ai​−Ai+1​)×T度
  • 如果A_i<A_{i+1}Ai​<Ai+1​由于海拔升高,风的温度会下降(A_{i+1}-A_i)\times S(Ai+1​−Ai​)×S度
输入格式:

从标准输入中读入下面的数据.

  • 第一行输入包括四个被空格隔开的整数N,Q,S,TN,Q,S,T.这表示JOI先生在地点NN有一所房子,有QQ次地壳运动,海拔每上升1米的话,风的温度会降低SS度,海拔每下降一米的话,风的温度会上升TT度.
  • 接下来的N+1N+1行中第ii行(1\leq i\leq N+1)(1≤i≤N+1)包含一个整数A_{i-1}Ai−1​,表示地壳运动前地点i-1i−1的海拔高度.
  • 接下来的QQ行中第jj行(1\leq j\leq Q)(1≤j≤Q)包括三个被空格隔开的整数L_j,R_j,X_jLj​,Rj​,Xj​.这表示第jj天地壳运动使地点L_jLj​到地点R_jRj​中这些地点的海拔变化了X_jXj​
输出格式:

输出QQ行,第jj行的输出代表第jj天地壳运动后JOI先生家的风的温度. (即NN位置的风的温度)

题目描述

输入格式

Read the following data from the standard input.

  • The first line of input contains four space separated integers N,Q,S,TN,Q,S,T . This means there is a house of Mr. JOI at Spot NN , there are QQ tectonic movements, the temperature of the wind decreases by SS degrees per altitude if the altitude increases, and the temperature of the wind increases by TT degrees per altitude if the altitude decreases.
  • The ii -th line (1\ \leq\ i\ \leq\ N+1)(1 ≤ i ≤ N+1) of the following N+1N+1 lines contains an integer A_{i−1} , which is the initial altitude at Spot (i\ −\ 1) before tectonic movements.
  • The jj -th line (1\ \leq\ j\ \leq\ Q)(1 ≤ j ≤ Q) of the following QQ lines contains three space separated integers L_j,\ R_j,\ X_jLj​, Rj​, Xj​ . This means, for the tectonic movement on the jj -th day, the change of the altitude at the spots from L_jLj​ to R_jRj​ is described by X_jXj​ .

输出格式

Write QQ lines to the standard output. The jj -th line (1\ \leq\ j\ \leq\ Q)(1 ≤ j ≤ Q) of output contains the temperature of the wind at the house of Mr. JOI after the tectonic movement on the jj -th day.

输入输出样例

输入 #1复制

3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5

输出 #1复制

-5
-7
-13
-13
-18

输入 #2复制

2 2 5 5
0
6
-1
1 1 4
1 2 8

输出 #2复制

5
-35

输入 #3复制

7 8 8 13
0
4
-9
4
-2
3
10
-9
1 4 8
3 5 -2
3 3 9
1 7 4
3 5 -1
5 6 3
4 4 9
6 7 -10

输出 #3复制

277
277
322
290
290
290
290
370

输入 #4复制

3 5 1 2
0
4
1
8
1 2 2
1 1 -2
2 3 5
1 2 -1
1 3 5

输出 #4复制

-5
-7
-13
-13
-18

输入 #5复制

2 2 5 5
0
6
-1
1 1 4
1 2 8

输出 #5复制

5
-35

输入 #6复制

7 8 8 13
0
4
-9
4
-2
3
10
-9
1 4 8
3 5 -2
3 3 9
1 7 4
3 5 -1
5 6 3
4 4 9
6 7 -10

输出 #6复制

277
277
322
290
290
290
290
370

说明/提示

課題

地殻変動が起きる前の標高と地殻変動の情報が与えられたとき,すべての整数 j\ (1\ ≦\ j\ ≦\ Q)j (1 ≦ j ≦ Q) に対し, jj 日目の地殻変動が起こった後の JOI 君の家に吹く風の温度を求めるプログラムを作成せよ.

制限

すべての入力データは以下の条件を満たす.

  • 1\ ≦\ N\ ≦\ 200\,0001 ≦ N ≦ 200000 .
  • 1\ ≦\ Q\ ≦\ 200\,0001 ≦ Q ≦ 200000 .
  • 1\ ≦\ S\ ≦\ 1\,000\,0001 ≦ S ≦ 1000000 .
  • 1\ ≦\ T\ ≦\ 1\,000\,0001 ≦ T ≦ 1000000 .
  • A_0\ =\ 0A0​ = 0 .
  • -1\,000\,000\ ≦\ A_i\ ≦\ 1\,000\,000\ (1\ ≦\ i\ ≦\ N)−1000000 ≦ Ai​ ≦ 1000000 (1 ≦ i ≦ N) .
  • 1\ ≦\ L_j\ ≦\ R_j\ ≦\ N\ (1\ ≦\ j\ ≦\ Q)1 ≦ Lj​ ≦ Rj​ ≦ N (1 ≦ j ≦ Q) .
  • -1\,000\,000\ ≦\ X_j\ ≦\ 1\,000\,000\ (1\ ≦\ j\ ≦\ Q)−1000000 ≦ Xj​ ≦ 1000000 (1 ≦ j ≦ Q) .

Task

Given the data of tectonic movements, write a program which calculates, for each j\ (1\ \leq\ j\ \leq\ Q)j (1 ≤ j ≤ Q) . the temperature of the wind at the house of Mr. JOI after the tectonic movement on the jj -th day.

Constraints

All input data satisfy the following conditions.

  • 1\ \leq\ N\ \leq\ 200\,0001 ≤ N ≤ 200000 .
  • 1\ \leq\ Q\ \leq\ 200\,0001 ≤ Q ≤ 200000 .
  • 1\ \leq\ S\ \leq\ 1\,000\,0001 ≤ S ≤ 1000000 .
  • 1\ \leq\ T\ \leq\ 1\,000\,0001 ≤ T ≤ 1000000 .
  • A_0\ =\ 0A0​ = 0 .
  • −1\,000\,000\ \leq\ A_i\ \leq\ 1\,000\,000\ (1\ \leq\ i\ \leq\ N) .
  • 1\ \leq\ L_j\ \leq\ R_j\ \leq\ N\ (1\ \leq\ j\ \leq\ Q)1 ≤ Lj​ ≤ Rj​ ≤ N (1 ≤ j ≤ Q) .
  • −1\,000\,000\ \leq\ X_j\ \leq\ 1\,000\,000\ (1\ \leq\ j\ \leq\ Q) .

Sample Explanation 1

最初,地点 0,\ 1,\ 2,\ 30, 1, 2, 3 の標高はそれぞれ 0,\ 4,\ 1,\ 80, 4, 1, 8 である. 11 日目の地殻変動の後,標高はそれぞれ 0,\ 6,\ 3,\ 80, 6, 3, 8 となる.このとき,地点 0,\ 1,\ 2,\ 30, 1, 2, 3 での風の温度はそれぞれ 0,\ -6,\ 0,\ -50, −6, 0, −5 となる.

Sample Explanation 2

この入力例は,小課題 2 の条件を満たす.

Sample Explanation 4

Initially, the altitudes of the spot 0,1,2,30,1,2,3 are 0,\ 4,\ 1,\ 80, 4, 1, 8 , respectively. After the tectonic movement on the first day, the altitudes become 0,\ 6,\ 3,\ 80, 6, 3, 8 , respectively. At that moment, the temperatures of the wind are 0,\ -6,\ 0,\ 50, −6, 0, 5 , respectively.

Sample Explanation 5

This sample input satisfies the constrains of Subtask 2.

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll s1,s2;
ll dif[300001];
ll get(ll t)
{if(t>0)return -s1*t;else return -s2*t;
}
int main()
{int num,query;scanf("%d%d%lld%lld",&num,&query,&s1,&s2);vector<int>v;for(int i=0;i<=num;i++){int z;scanf("%d",&z);v.push_back(z);}ll ans=0;for(int i=0;i<num;i++){dif[i]=v[i+1]-v[i];ans+=get(dif[i]);}for(int i=0;i<query;i++){int za,zb,zc;scanf("%d%d%d",&za,&zb,&zc);ans-=get(dif[za-1]);dif[za-1]+=zc;ans+=get(dif[za-1]);if(zb!=num){ans-=get(dif[zb]);dif[zb]-=zc;ans+=get(dif[zb]);}printf("%lld\n",ans);}return 0;
}

转载于:https://www.cnblogs.com/hrj1/p/11197450.html

フェーン現象 (Foehn Phenomena)相关推荐

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

    洛谷 AT2442 フェーン現象 (Foehn Phenomena) 题目链接 题意: 自己看 思路: 当前地点温度其实只和前一个地点有关,可以考虑差分,每次变动时先减去原地点产生的影响,在加上变动后 ...

  2. 【AtCoder2442】フェーン現象 (Foehn Phenomena)

    题面 分析 这道题其实是差分模板qvq 区间修改 单点查询 而且题面也疯狂暗示,相邻两点海拔差,用差分简直是按照出题人意思来的,而且人性化的是n+1个点刚好n个区间,查询也只用查询第n点. 同时,知道 ...

  3. [AT2442]フェーン現象 (Foehn Phenomena)

    题目大意:一个数组$A$和$P$,若$A_i>A_{i+1}$,$P_{i+1}=P_i+(A_i-A_{i+1})\times S$,否则$P_{i+1}=P_i-(A_{i+1}-A_i)\ ...

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

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

  5. 【洛谷AT2442】フェーン現象(Foehn Phenomena)【线段树】

    linklinklink 分析: 都说是裸差分 那就线段树做( 海拔的上升与下降 就区间修改 答案就单点查询 具体的就跟题意模拟了 然后注意a0a_0a0​是000 那n,x,yn,x,yn,x,y啥 ...

  6. Foehn Phenomena

    题目链接 解题思路:利用差分数组,此时得到每两个元素的差值,从首位置加到当前节点可以得到当前节点对应的元素.差分数组可以高效的改变区间值.当同时给[ l, r] 的元素 加x 时, 只需将差分数组 l ...

  7. 2019.2-2019.3 TO-DO LIST

    DP P2723 丑数 Humble Numbers(完成时间:2019.3.1) P2725 邮票 Stamps(完成时间:2019.3.1) P1021 邮票面值设计(完成时间:2019.3.1) ...

  8. 一些根本不用数据结构的题。。(积木大赛、焚风现象)

    我发现我学数据结构学傻啦..看题和数据范围就会想到些数据结构... 春春幼儿园举办了一年一度的"积木大赛".今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木 ...

  9. 纯php实现定时器任务,純PHP實現定時器任務(Timer)

    定時器任務,在WEB應用比較常見,如何使用PHP實現定時器任務,大致有兩種方案:1)使用Crontab命令,寫一個shell腳本,在腳本中調用PHP文件,然后定期執行該腳本:2)配合使用ignore_ ...

最新文章

  1. mysql数据库blob区别_MySQL中TEXT与BLOB字段类型的区别
  2. HTML5怎么让图片和文字重叠,利用HTML5实现全屏图片文字过渡切换特效
  3. 教程-经典Delphi教程网
  4. 十八、深入Java 访问修饰符和非访问修饰符
  5. 成为人上人,而不是人上人永远的崇拜者
  6. 机器学习算法优缺点改进总结
  7. Bitmap详解(中)之像素级操作
  8. fileinputstream读取文件_压缩 20M 文件从 30 秒到 1 秒的优化过程
  9. 微信小程序多位验证码/密码输入框
  10. Android开发之在不同API上遇见的坑
  11. java集合之Stack栈基础
  12. sxssfworkbook 设置单元格大小_Offset属性和Resize属性相结合,完美实现选择区域大小的改变...
  13. python 共享文件_通过 Python 快速实现局域网内文件共享
  14. java restsharp_RestSharp使用总结
  15. java日期格式_java日期和时间的格式化
  16. 超频真的不难!G3258超频4.5GHz全攻略
  17. python base_Python base(一)
  18. PTMs-GPT,GPT2
  19. HCSC: Hierarchical Contrastive Selective Coding
  20. java基于微信小程序的驾校报名预约管理系统 uniapp 小程序

热门文章

  1. Python爬虫:爬取百度图片(selenium模拟登录,详细注释)
  2. vm服务器虚拟化迁移,在线迁移演示(存储在线迁移、虚拟机在线迁移)
  3. C# vb .net实现gamma伽玛调整特效滤镜
  4. vue中不同模块间的跳转
  5. 计算1900年1月1日到当前年份的日期之间一共有多少天
  6. 领扣--唯一摩尔斯密码
  7. []==''返回?为什么?运算符==进行了什么操作?
  8. macOS如何快速将视频转化为音频mp3(软件全免费)
  9. css3实现六边形列表
  10. Json的FastJson与Jackson