Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 933/E. Rudolf and k Bridges
Next
CodeforcesCodeforces
Candidate Master
Codeforces Round 933

E. Rudolf and k Bridges

Dynamic ProgrammingPrefix SumQueueSliding WindowGreedy
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

Bernard loves visiting Rudolf, but he is always running late. The problem is that Bernard has to cross the river on a ferry. Rudolf decided to help his friend solve this problem. The river is a grid of 𝑛 rows and π‘š columns. The intersection of the 𝑖 -th row and the 𝑗 -th column contains the number π‘Žπ‘–,𝑗 β€” the depth in the corresponding cell. All cells in the first and last columns correspond to the river banks, so the depth for them is 0 . The river may look like this. Rudolf can choose the row (𝑖,1),(𝑖,2),…,(𝑖,π‘š) and build a bridge over it. In each cell of the row, he can install a support for the bridge. The cost of installing a support in the cell (𝑖,𝑗) is π‘Žπ‘–,𝑗+1 . Supports must be installed so that the following conditions are met: A support must be installed in cell (𝑖,1) ; A support must be installed in cell (𝑖,π‘š) ; The distance between any pair of adjacent supports must be no more than 𝑑 . The distance between supports (𝑖,𝑗1) and (𝑖,𝑗2) is |𝑗1βˆ’π‘—2|βˆ’1 . Building just one bridge is boring. Therefore, Rudolf decided to build π‘˜ bridges on consecutive rows of the river, that is, to choose some 𝑖 (1β‰€π‘–β‰€π‘›βˆ’π‘˜+1 ) and independently build a bridge on each of the rows 𝑖,𝑖+1,…,𝑖+π‘˜βˆ’1 . Help Rudolf minimize the total cost of installing supports.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 933
Next Problem