Problem from one Serbian contest

Revision en1, by Brankonymous, 2018-10-29 23:09:10

Hi, can someone help me solve this problem:

Input consist of integer n and array a of n integers. Output number of pairs (a[i],a[j]), i<j who are adjacent or for all k (i<k<j) this equation is true: a[k]<=min(a[i],a[j]).

1<=n<=10^6

0<=a[i]<=2^31

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Brankonymous 2018-10-29 23:10:57 50 Tiny change: 'a[i]<=2^31' -> 'a[i]<=2^31\n\nexample:\n\n8\n\n4 1 2 3 6 5 1 2\n\nOutput: 11'
en1 English Brankonymous 2018-10-29 23:09:10 287 Initial revision (published)