Skip to content

Instantly share code, notes, and snippets.

@diego9627
Created December 18, 2012 00:09
Show Gist options
  • Save diego9627/4323641 to your computer and use it in GitHub Desktop.
Save diego9627/4323641 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
ifstream fin("wifi.in");
ofstream fout("wifi.out");
int main(){
long long int N,A,B,cows[1001],cost=0;
fin >> N >> A >> B;
for(int i=0;i<N;i++) fin >> cows[i];
sort(cows,cows+N);
cost=2*A;
for(int i=1;i<N;i++){
cost+=min(2*A,(cows[i]-cows[i-1])*B);
}
fout << (cost/2);
if(cost%2) fout << '.' << 5 << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment