-
Notifications
You must be signed in to change notification settings - Fork 1
/
11389 - The Bus Driver Problem.cpp
40 lines (36 loc) · 1.09 KB
/
11389 - The Bus Driver Problem.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,d,r;
std::vector<int> morning;
std::vector<int> evening;
while(cin>>n>>d>>r) {
if(!n && !d && !r)
break;
for(int i=0; i<n; i++)
{
int temp;
cin>>temp;
morning.push_back(temp);
}
for(int i=0; i<n; i++)
{
int temp;
cin>>temp;
evening.push_back(temp);
}
sort(morning.begin(),morning.end());
sort(evening.begin(),evening.end(),greater<int>());
int total=0;
for(int i=0;i<n;i++){
int temp=morning[i]+evening[i];
temp-=d;
if(temp>0)
total+=temp*r;
}
cout<<total<<endl;
morning.clear();
evening.clear();
}
return 0;
}