Source Code
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;
int n;
long long A[N] ; 
long long h, a; 
int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
#endif
       cin >> n >> a >> h ; 
       long long tot = a ; 
       for(int i = 0 ;i < n; ++ i){
              cin >> A[i] ; 
              tot += A[i] ; 
       }
       h%=tot ; 
       int ans = (h <= a) ; 
       for(int i = 0 ;i < n; ++ i){
              h-= A[i] ; 
              if(h > 0){
                     ans += h <= a; 
              }
       }
       cout << ans; 
       return 0;
}
Copy
Treasure Mohamed.Sobhy
GNU G++17
17 ms
2.4 MB
Accepted