B. Elementary Particles

Правка en1, от witty-v, 2022-03-28 14:18:21

1625B - Elementary Particles The problem need us giving two same length sequence. Assuming the length of sequence is n. that one's index from 1 to n — 1, another from 2 to n. And two sequence at least exists one index position, make the value of same index is same and the length of sequence as large as possible.

Now that the value is same, we can enumberate the gived array, suppose a value A in array is correct answer. To find out same value B , calculating distance between B to last element in array and plus the distance between the first element to A. So we can summarize a formula. suppose lenA is the length that 0 to index of A lenB is the length that B to index of n ans = lenA + lenB

Теги array, greedy

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский witty-v 2022-03-28 14:40:17 1528 (published)
en1 Английский witty-v 2022-03-28 14:18:21 737 Initial revision (saved to drafts)