11389 – The Bus Driver Problem

Problem Link

<Source Code>

#include<cstdio>
#include<functional>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
int n,d,r,i,j;
while(scanf(“%d %d %d”,&n,&d,&r) && n &&d &&r)
{
int a[1000],b[1000],dif=0,num,time,money=0;
for(i=0;i<n;i++)
{scanf(“%d”,&a[i]);
}
sort(a,a+n);
for(i=0;i<n;i++)
{scanf(“%d”,&b[i]);
}
sort(b,b+n,greater<int>());

*/greater<int> g; // a > b
sort(a,a+strlen(a),g);
For details

for(i=0;i<n;i++)
{time=a[i]+b[i];
if(time>d)
money+=(time-d)*r;
}
printf(“%d\n”,money);
}
return 0;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s