Pagini recente » Cod sursa (job #2964390) | Cod sursa (job #2786215) | Cod sursa (job #1108149) | Cod sursa (job #1391029) | Cod sursa (job #635937)
Cod sursa(job #635937)
#include<fstream>
#include<string>
using namespace std;
int t[1000005],p,l;
string s;
ifstream fin("zombie.in");
int citire(){
int aux=0;
while(p<l && s[p]>='0' && s[p]<='9'){
aux=aux*10+s[p]-48;
if(p<l-1)++p; else break;
}
while(p<l && (s[p]<'0' || s[p]>'9')){
if(p<l-1)++p; else break;
}
return aux;
}
int main(void){
ofstream fout("zombie.out");
int n,d,k,i=1,j,cost=0;
fin>>n>>d>>k; getline(fin,s);
getline(fin,s); l=s.length(); p=0;
for(i=1;i<=n;++i)t[i]=citire();
for(i=1;i<=n;++i)fout<<t[i];
while(i<=n){
j=i+1;
while(t[j]-t[i]<d && j<=n)++j;
if(k<j-i)cost+=k;
else cost+=j-i;
i=j;
}
fout<<cost; fout.close();
return 0;
}