303693: CF714A. Meeting of Old Friends
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Meeting of Old Friends
题意翻译
## 题目描述 今天森林里将要发生一件大事——刺猬 Filya 要去看望他的老朋友 Sonya! Sonya 身为一只傲娇的猫头鹰,当然要在白天睡觉。不过,她会在 $[l_1,r_1]$ 分钟内会保持清醒。作为一只美美的猫头鹰,在第 $k$ 分钟,Sonya 会补妆,这时她和 Filya 不能在一起。 Filya 有很多工作要做,他预计在 $[l_2,r_2]$ 分钟去探望 Sonya。 请你计算两人可以相处多长时间。 ## 输入格式 一行,五个整数 $l_1,r_1,l_2,r_2$ 和 $k(1 \le l_1,r_1,l_2,r_2,k \le 10^{18},l_1 \le r_1,l_2 < r_2)$。 ## 输出格式 一个整数,表示 Sonya 和 Filya 的相处时间。 ## 说明 ### 【样例一解释】 在第 $[9,10]$ 分钟相处。 ### 【样例二解释】 在第 $[50,74]$ 分钟和第 $[76,100]$ 分钟在一起,第 $75$ 分钟时 Sonya 当然是去补妆辣! Translated by @Ehrgeiz @I_love_him52题目描述
Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya! Sonya is an owl and she sleeps during the day and stay awake from minute $ l_{1} $ to minute $ r_{1} $ inclusive. Also, during the minute $ k $ she prinks and is unavailable for Filya. Filya works a lot and he plans to visit Sonya from minute $ l_{2} $ to minute $ r_{2} $ inclusive. Calculate the number of minutes they will be able to spend together.输入输出格式
输入格式
The only line of the input contains integers $ l_{1} $ , $ r_{1} $ , $ l_{2} $ , $ r_{2} $ and $ k $ ( $ 1<=l_{1},r_{1},l_{2},r_{2},k<=10^{18} $ , $ l_{1}<=r_{1} $ , $ l_{2}<=r_{2} $ ), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.
输出格式
Print one integer — the number of minutes Sonya and Filya will be able to spend together.
输入输出样例
输入样例 #1
1 10 9 20 1
输出样例 #1
2
输入样例 #2
1 100 50 200 75
输出样例 #2
50