DOJ logoDOJ
Problems
Recently added problemsSaved problemsWorkbooks
CategoriesDLCContestsGroupsTeamsBoard
Ranking
Solved Problem RankingStreak rankingDOJ Power ranking
Status
Call for TasksLoginRegister
DOJ logoDOJ

Community online judge with OI-style subtask scoring, Elo ratings, and Discord account linking.

Problems
ProblemsCategories
Community
ContestsRankingBoardNoticesHost an external contestGuide
Account
LoginRegisterJudge Status
Policy
Terms of ServiceDLC RulesPrivacyAPI documentationLanguage runtimesContest rank rewardsRating and performance
© 2026 DOJ
All rights reserved
Editorial

Dadas Is Short

Back to problem

Editorial

Every interval containing person 111 has L=1L=1L=1. Increase the right endpoint RRR from 111. Once the first position R>1R>1R>1 with HR≥H1H_R \geq H_1HR​≥H1​ is reached, that interval and every longer interval fail. Hence the answer is the number of positions before it. The time complexity is O(N)O(N)O(N).