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<

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<

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

Why Home Office Lighting Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

What does rat scat look like?

Discovering unwanted pests in your living space is a homeowner's worst nightmare. Among the clearest signals of a rodent problem is finding fecal matter...

How to Use Snail Mucin Essence on Face (Complete Beginner’s Guide)

Overview: How to Use Snail Mucin Essence on Face (Complete Beginner's Guide) Finding reliable, data-backed guidance on how to use snail mucin essence on face...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!