Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- ll n,k; cin>>n>>k;
- vector<ll> v(n);
- for(auto&i:v) cin>>i;
- ll ans = n*(n+1)/2;
- ll exclude = 0;
- ll l=0,r=0, sum = 0;
- while(r<n){
- sum += v[r];
- while(sum >= k){
- sum -= v[l];
- l++;
- }
- exclude += r-l+1;
- r++;
- }
- cout<<ans-exclude<<nl;
- }
- int main(){
- files();
- int t = 1;
- // cin>>t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement