Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * author: NEZZ
- **/
- #include <bits/stdc++.h>
- #define rep(i,a,b) for (int i=a;i<b;i++)
- #define rep2(i,a,b) for (int i=a;i>=b;i--)
- #define mod 1000000007
- #define f first
- #define s second
- #define endl '\n'
- #define ll long long
- #define pii pair <int,int>
- #define pll pair <ll,ll>
- #define vi vector <int>
- #define vl vector <ll>
- #define vll vector < pll >
- #define vii vector < pii >
- #define vb vector <bool>
- #define pb push_back
- #define mk make_pair
- #define sz(a) a.size()
- #define all(a) a.begin(),a.end()
- #define rall(a) a.rbegin(),a.rend()
- #define input freopen("intput","r",stdin)
- #define output freopen("output","w",stdout)
- #define fastIO ios_base::sync_with_stdio (0),cin.tie(0)
- #define debug input,output
- using namespace std;
- void affiche (int t[],int n){ rep (i,0,n) cout<<t[i]<<" ";cout<<endl;}
- void afficheV (vi t){rep (i,0,sz(t))cout<<t[i]<<" ";cout<<endl;}
- int main (){
- fastIO;
- int n,d;
- cin>>n>>d;
- int t[n];
- ll sum[n];
- bool cond=true;
- int c=0;
- rep (i,0,n){
- cin>>t[i];
- if (i==0)
- sum[i]=t[i];
- else sum[i]=sum[i-1]+t[i];
- if (t[i]==0){
- c+=(sum[i]<0);
- }
- if (sum[i]>d)
- cond=false;
- }
- if (cond)
- cout<<c;
- else cout<<-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement