Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created April 16, 2014 14:29
Show Gist options
  • Save KT-Yeh/10884906 to your computer and use it in GitHub Desktop.
Save KT-Yeh/10884906 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <algorithm>
int main()
{
int n, d, r;
int morning[105], night[105];
while (scanf("%d %d %d", &n, &d, &r) && (n || d || r)) {
for (int i = 0; i < n; ++i) scanf("%d", &morning[i]);
for (int i = 0; i < n; ++i) scanf("%d", &night[i]);
std::sort(morning, morning + n);
std::sort(night, night + n);
int fine = 0;
for (int i = 0; i < n; ++i)
if (morning[i] + night[n-i-1] > d)
fine += ((morning[i] + night[n-i-1] - d) * r);
printf("%d\n", fine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment