请教如何使用C语言来解决一个天气的预测的问题的

Problem Description
"Man, this year has the worst weather ever!", David said as he sat crouched in the small cave where we had sought shelter from yet another sudden rainstorm.
"Nuh-uh!", Diana immediately replied in her traditional know-it-all manner.
"Is too!", David countered cunningly. Terrific. Not only were we stuck in this cave, now we would have to listen to those two nagging for at least an hour. It was time to cut this discussion short.
"Big nuh-uh. In fact, 93 years ago it had already rained five times as much by this time of year."
"Duh", David capitulated, "so it's the worst weather in 93 years then."
"Nuh-uh, this is actually the worst weather in 23 years.", Diana again broke in.
"Yeah, well, whatever", David sighed, "Who cares anyway?".
Well, dear contestants, you care, don't you?
Your task is to, given information about the amount of rain during different years in the history of the universe, and a series of statements in the form "Year X had the most rain since year Y", determine whether these are true, might be true, or are false. We say that such a statement is true if:

The amount of rain during these two years and all years between them is known.

It rained at most as much during year X as it did during year Y.

For every year Z satisfying Y < Z < X, the amount of rain during year Z was less than the amount of rain during year X.

We say that such a statement might be true if there is an assignment of amounts of rain to years for which there is no information, such that the statement becomes true. We say that the statement is false otherwise.

Input
The input will consist of several test cases, each consisting of two parts.
The first part begins with an integer 1 <= n <= 50000, indicating the number of different years for which there is information. Next follow n lines. The ith of these contains two integers -109 <= yi <= 109 and 1 <= ri <= 109 indicating that there was ri millilitres of rain during year yi (note that the amount of rain during a year can be any nonnegative integer, the limitation on ri is just a limitation on the input). You may assume that yi < yi+1 for 1 <= i < n.
The second part of a test case starts with an integer 1 <= m <= 10000, indicating the number of queries to process. The following m lines each contain two integers -109 <= Y < X <= 109 indicating two years.
There is a blank line between test cases. The input is terminated by a case where n = 0 and m = 0. This case should not be processed.
Technical note: Due to the size of the input, the use of cin/cout in C++ might be too slow in this problem. Use scanf/printf instead. In Java, make sure that both input and output is buffered.

Output
There should be m lines of output for each test case, corresponding to the m queries. Queries should be answered with "true" if the statement is true, "maybe" if the statement might be true, and "false" if the statement is false.
Separate the output of two different test cases by a blank line.

Sample Input
4
2002 4920
2003 5901
2004 2832
2005 3890
2
2002 2005
2003 2005

3
1985 5782
1995 3048
2005 4890
2
1985 2005
2005 2015

0
0

Sample Output
false
true

maybe
maybe

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
c语言 struct携带参数问题
1
一个有关于连接图论的问题,请教各位高手了怎么解决,用C语言
1
一个随机漫步的问题,使用C语言的算法实现,请教下怎么实现才能解决
0
一个和概率生成有关的算法问题,请教如何利用C语言的综合技术编写?
0
请问请教这里的翻纸牌的游戏的问题,如何利用C语言的思路去解决
0
请教各位神人看下这里的C语言如何才能高效解决楼梯数列推导的问题
0
字符串带格式的格式化的问题算法,请教如何利用C语言的方式实现
2
小白请教一个关于C语言字符串的问题?
0
请教节点的访问性的算法计算的问题,怎么采用C语言程序代码编写过程的思路实现
0
通过程序判断s2 是s1的亲和串,具体使用C语言这个程序设计语言的代码的编写的技术如何实现的?
1
C语言 请教有关最短路径算法的伪代码
0
用字符串的形式去输出表情的一个问题,请教运用什么算法用C语言的程序的编写的过程去实现呢?
1
请教大家两个关于QT的问题,解决一个算一个~
0
题目问问最少可使卡上的余额为多少,请教如何利用C语言的程序编写代码实现的技术来求
1
请教一个Java高并发的设计问题与我目前的解决方法
1
请教#c语言,主函数中调用哪里出错?
1
LSTM模型如何进行新数据的预测?
1
新手请教一下c语言变量定义的问题
1
请教大佬一个关于文件流输入的语言问题
2
请教一下各位前辈, 关于rsa算法理解的问题