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-backed certification.

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

Finding Experts

Back to problem

Editorial

A user with rating CCC and solved-problem count DDD is recognized by everyone precisely when C≥AiC \ge A_iC≥Ai​ and D≥BiD \ge B_iD≥Bi​ hold for every iii.

Let MA=max⁡1≤i≤NAiM_A = \max_{1 \le i \le N} A_iMA​=max1≤i≤N​Ai​ and . The conditions are equivalent to and .

For each test case, compute both maxima and count users satisfying Ci≥MAC_i \ge M_ACi​≥MA​ and Di≥MBD_i \ge M_BD.

The time complexity is O(N)O(N)O(N) per test case and O(∑N)O(\sum N)O(∑N) overall. The space complexity is O(N)O(N)O(N). Solution written by GPT6

MB=max⁡1≤i≤NBiM_B = \max_{1 \le i \le N} B_iMB​=max1≤i≤N​Bi​
C≥MAC \ge M_AC≥MA​
D≥MBD \ge M_BD≥MB​
i
​
≥
MB​