-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC_Boring_Day.cpp
67 lines (55 loc) · 1.38 KB
/
C_Boring_Day.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <bits/stdc++.h>
using namespace std;
#define int long long
using pii = pair<int, int>;
#define forr(i, n) for (int i = 0; i < n; i++)
#define reforr(i, n) for (int i = n; i >= 0; i--)
#define eqforr(i, a, n) for (int i = a; i <= n; i++)
#define sqforr(i, n) for (int i = 1; i * i <= n; i++)
#define genforr(i, a, b) for (int i = a; i < b; i++)
#define pba push_back
#define popb pop_back
#define popf pop_front
#define allEle(x) (x).begin(), (x).end()
#define allRle(x) (x).rbegin(), (x).rend()
typedef vector<int> vint;
typedef vector<string> vstr;
#define vcstr(vstr, n) forr(i, n) cin >> vstr[i]
#define vcin(vint, n) forr(i, n) cin >> vint[i]
#define vpin(vint) for (auto x : vint) cout << x << " "; cout << endl;
#define vpstr(vstr) for (auto x : vstr) cout << x << " "; cout << endl;
const int inf = 1e9 + 5;
int digitSum(int n) {
if (n < 10) return n;
return n % 10 + digitSum(n / 10);
}
void solve() {
int n, l, r;
cin >> n >> l >> r;
vint a(n);
vcin(a, n);
int ans = 0;
int sum = 0;
int p1 = 0;
for (int p2 = 0; p2 < n; ++p2) {
sum += a[p2];
while (sum > r && p1 <= p2) {
sum -= a[p1];
p1++;
}
if (sum >= l && sum <= r) {
ans++;
sum = 0;
p1 = p2 + 1;
}
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
for (int i = 0; i < t; i++)
solve();
}