#P16238. [蓝桥杯 2026 省 B] 理想温度
[蓝桥杯 2026 省 B] 理想温度
Problem Description
On an industrial production line, there are temperature sensors arranged in order. The current temperatures measured by the sensors are recorded in array , and the corresponding ideal target temperatures are recorded in array (that is, is the current temperature of the -th sensor, and is the ideal temperature of the -th sensor).
To make as many sensors as possible reach the ideal temperature, you may perform one range temperature compensation operation:
- Choose a continuous interval of sensors on the line (i.e., the -th to the -th sensors).
- Input a compensation value ( can be any integer), so that the current temperature of every sensor in this interval is increased by .
After performing this single calibration operation, what is the maximum number of sensors whose temperatures can be exactly equal to their corresponding ideal target temperatures?
Input Format
The first line contains an integer , representing the number of sensors.
The second line contains integers , representing the current temperatures of the sensors.
The third line contains integers , representing the ideal target temperatures of the sensors.
Output Format
Output one line containing an integer, representing the maximum number of sensors that are at the ideal temperature after the compensation operation.
5
1 2 3 4 5
2 3 2 3 2
2
Hint
Constraints
For of the testdata, it is guaranteed that .
For all testdata, it is guaranteed that , .
Translated by ChatGPT 5