-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbusDrive.cpp
57 lines (47 loc) · 1.09 KB
/
busDrive.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
ifstream fin("busDrive.in");
ofstream fout("busDrive.out");
int main()
{
while (true)
{
int n = -1, d = -1, r = -1;
fin >> n >> d >> r;
if (n == 0)
{
break;
}
vector<int> morning(n), evening(n);
for (int i = 0; i <= n - 1; ++i)
{
fin >> morning[i];
}
for (int i = 0; i <= n - 1; ++i)
{
fin >> evening[i];
}
sort(morning.begin(), morning.end());
sort(evening.begin(), evening.end(), greater<int>());
int total = 0;
for (int i = 0; i <= n - 1; ++i)
{
if (morning[i] + evening[i] > d)
{
total += morning[i] + evening[i] - d;
}
}
fout << total * r << '\n';
}
return 0;
}