Source Code
#include <bits/stdc++.h>
#define endl "\n"
#define debug(a) cout << #a << ": " << a << endl
#define debugLine() cout << "==============" << endl
#define tick() cout << "Tick" << endl
#define testCases() int t; cin >> t; while(t--)
#define all(a) a.begin(), a.end()
#define fillWith(a, b) memset(a, b, sizeof(a))
#define Mod 1000000007
#define goFast() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define files(x) freopen(x, "r", stdin)
typedef long long ll;
typedef long double ld;
using namespace std;

#define int long long

int theyD[200005 + 3];


main()
{
    goFast();
    int N, meD, depth;
    cin >> N >> meD >> depth;
    int sum = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> theyD[i];
        sum += theyD[i];
    }
    sum += meD;
    int sum2 = 0;
    int counter = 0;
    if(depth % sum == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    for(int i = 0; i <= N; i++)
    {
        if(((depth % sum) - sum2) <= meD && ((depth % sum) - sum2) > 0)
            counter++;
        if(i != N)
            sum2 += theyD[i];
    }
    cout << counter << endl;
}
Copy
Treasure AhmadShahal
GNU G++17
15 ms
2.4 MB
Accepted