Source Code
#include <iostream>
#include <vector>
#define int long long
using namespace std;
int v[1010000];
int a[1001000];
signed main()
{
    int n,m,d;
    cin>>n>>m>>d;
    int h=0;
    for(int i=0; i<n; i++)
    {
        //h+=a[i];
        cin>>a[i];
        h+=a[i];
    } h+=m;
    int vv=d/h;
    vv*=h;
    d-=vv;
    int g=0;
    int j=0;
    for(int i=0;i<=2*n ; i++)
    {

        if(g+m>=d)
        {
            if(!v[i%n])
            {
                j++;
                v[i%n]=1;
            }
        }
        g+=a[i%n];
        if(g>=d)
            break;

    }
    cout<<"            "<<j<<endl;

}
Copy
Treasure CR7
GNU G++17
1 ms
804 KB
Wrong Answer