rt,不知道有没有人听说过一个叫尺取俗称毛毛虫的算法,反正很灵异的就是本地跑的都对,一交上去就0分
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
void best_coder() {
int n;
long long l, r;
scanf("%d%lld%lld", &n, &l, &r);
vector<long long> a(n + 1, 100000);
for (int i = 0; i < n; ++i) {
scanf("%lld", &a[i]);
}
int i = 0;
int j = 0;
long long cnt = 0;
long long ans = 0;
while (i < n) {
if (cnt >= l && cnt <= r && i != j) {
++ans;
}
if (cnt + a[j] <= r) {
cnt += a[j];
++j;
} else if (i == j) {
++i;
++j;
} else {
cnt -= a[i];
++i;
}
}
printf("%lld\n", ans);
}
void happy_coder() {
}
int main() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// 小码匠
best_coder();
// 最优解
// happy_coder();
// 返回
return 0;
}