-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbusDriveOJ.cpp
58 lines (48 loc) · 1.1 KB
/
busDriveOJ.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
58
#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;
int main()
{
ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
while (true)
{
int n = -1, d = -1, r = -1;
cin >> n >> d >> r;
if (n == 0)
{
break;
}
vector<int> morning(n), evening(n);
for (int i = 0; i <= n - 1; ++i)
{
cin >> morning[i];
}
for (int i = 0; i <= n - 1; ++i)
{
cin >> 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;
}
}
cout << total * r << '\n';
}
cout.flush();
return 0;
}