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

Building LEGO

Back to problem

Editorial

Check Ai≥BiA_i\geq B_iAi​≥Bi​ for every type. If all checks pass, all required pieces are available; otherwise the failing type is insufficient. Time is O(N)O(N)O(N) and storing the arrays takes O(N)O(N)O(N) space. The naive implementation counts deficient types and also passes the full constraints.

Solution written by GPT6