Codeforces Round #377 (Div. 2), problem: (B) Cormen — The Best Friend Of a Man Solution in C++

Hi guys , I just solved the Codeforces Round #377 (Div. 2), problem: (B) Cormen — The Best Friend Of a Man, hope you like it .
You are most welcome to submit any other solution .

include
using namespace std;
int main()
{
int n, walk, i, a[500], rem[500], flag, j, h, ans, temp;

cin>>n>>walk;
flag=0;
ans=0;
for(i=0,j=0; i>a[i];
if(i==0)
continue;
if((a[i]+a[i-1])=0)
{
ans += temp;
a[h] += temp;
}
if(h!=rem[i+1])
{
temp=walk-a[h]-a[h+1];
if(temp>=0)
{
ans += temp;
a[h+1] += temp;
}
}
}
}

cout<

A Sea Cucumber’s Amputated...

The Mystery of the Undying Sea Cucumber TissueNature never...

DraftKings: Prediction Markets Are...

The online sports betting landscape is shifting rapidly, and...

A Sea Cucumber’s Amputated Tissue Refuses To Die. Could It Live Forever?

The Mystery of the Undying Sea Cucumber TissueNature never ceases to amaze, and the latest discovery in marine biology has left scientists questioning the...

Why Everyone is Obsessed with the Car Seat Gap Organizer

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Reusable Lint Roller

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

DraftKings: Prediction Markets Are Eating This Company’s Lunch (Rating Downgrade)

The online sports betting landscape is shifting rapidly, and industry giant DraftKings (DKNG) is finding itself in increasingly turbulent waters. Once the undisputed darling...

Why Everyone is Obsessed with the Universal Charging Cable

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Fridge Odor Eliminator

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Hegseth Hails US Allies in Asia, Hits Out at Europe Partners

In a striking shift of foreign policy rhetoric, newly appointed U.S. Defense Secretary Pete Hegseth has praised America's allies in Asia while delivering sharp...

Why Everyone is Obsessed with the Reusable Silicone Food Bags

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...

Why Everyone is Obsessed with the Motion Sensor Night Lights

Are you tired of dealing with everyday frustrations that slow down your routine? We've all been...