Created
June 9, 2020 16:55
-
-
Save musou1500/c65a834ba48ec2bac2c5bffb6b3cd4f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ll = long long; | |
ll Inchworm(vector<ll> &va, ll k) { | |
ll left, right, sum, ans; | |
left = right = sum = ans = 0; | |
while (left < va.size()) { | |
while (right < n && sum + va[right] < k) { | |
sum += va[right]; | |
right++; | |
} | |
ll cnt = va.size() - right; | |
ans += cnt; | |
sum -= va[left]; | |
if (left == right) { | |
right++; | |
sum = 0; | |
} | |
left++; | |
} | |
return ans; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment