Input: 10 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Output: 0

Explanation: In each pair, the first number is not greater than the second number. Therefore, the maximum number of questions the person can ask is 0.

Input: 10 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19

Output: 10

Explanation: In each pair, the first number is greater than the second number. Therefore, the maximum number of questions the person can ask is equal to the difference between the first and second numbers in each pair, which is 1+1+1+1+1+1+1+1+1+1 = 10

#include iostreamusing namespace std;int main int n; cin n; int maxQuestions = 0; for int i = 0; i n; i++ int a b; cin a b; if a b maxQuestions += a

原文地址: http://www.cveoy.top/t/topic/idd0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录