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<

Leave a Reply

Your email address will not be published. Required fields are marked *