Cod sursa(job #2641224)

Utilizator xCata02Catalin Brita xCata02 Data 10 august 2020 16:50:15
Problema Zombie Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

#define Nmax 20005

ifstream fin  ("zombie.in");
ofstream fout ("zombie.out");

#define cin  fin
#define cout fout


/*
ifstream fin("test.in");
#define cin fin
*/

void solve() {
    ll d, m, k;
    ll sol = 0;
    cin >> d >> m >> k;
    ll first; cin >> first;
    ll contor = 1;
    for(ll i = 2; i <= m; i++) {
        int second; cin >> second;
        if(second - first >= d - 1) { ///  daca depasesc momentu de timp dau clear
            sol += min(contor, k);
            contor = 1;
            first = second;
        } else {
            contor++; /// cresc momentul de timp
        }
    }

    sol += min(contor, k); /// adaug ce a mai ramas
    cout << sol;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin .tie(0);
	cout.tie(0);

	int testCases = 1;
	//cin >> testCases;
	while(testCases--) {
		solve();
	}
}