WORKB
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
int count = 0;
while(t--)
{
count++;
int nevents,fare,penalty;
cin>>nevents>>fare>>penalty;
long long int total = 0;
int day;
int temp2;
for(int x=0;x<nevents;x++)
{
cin>>day;
if(x!=0)
{
if(((day - temp2 - 1)*penalty)<(2*fare))
{
total+= ((day - temp2)*penalty);
}
else
{
total+= (2*fare)+penalty;
}
}
else
{
total+=(fare + penalty);
}
if(x==nevents-1)
total+=fare;
temp2 = day;
}
cout<<"Case #"<<count<<": "<<total<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
int count = 0;
while(t--)
{
count++;
int nevents,fare,penalty;
cin>>nevents>>fare>>penalty;
long long int total = 0;
int day;
int temp2;
for(int x=0;x<nevents;x++)
{
cin>>day;
if(x!=0)
{
if(((day - temp2 - 1)*penalty)<(2*fare))
{
total+= ((day - temp2)*penalty);
}
else
{
total+= (2*fare)+penalty;
}
}
else
{
total+=(fare + penalty);
}
if(x==nevents-1)
total+=fare;
temp2 = day;
}
cout<<"Case #"<<count<<": "<<total<<endl;
}
return 0;
}
No comments:
Post a Comment