#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m;
int d[N];
long long a[N];
vector< vector<int> > vec;
int main() {
ios::sync_with_stdio(false);
cin >> n >> m;
a[0] = 1;
for (int i = 1; i <= n; ++i) {
cin >> d[i];
int tmp = (d[i] + (a[i - 1] - 1)) / a[i - 1];
a[i] = tmp * a[i - 1];
}
vector<int> cur;
cur.push_back(0);
for (int i = 1; i <= n; ++i) {
if (a[i] != a[cur.back()]) {
vec.push_back(cur), cur.clear();
}
cur.push_back(i);
}
vec.push_back(cur);
for (int i = 1; i <= m; ++i) {
int t, l, r; cin >> t >> l >> r;
int res = 0;
for (int j = 0; j < vec.size(); ++j) {
int tmp = t / a[vec[j][0]] * a[vec[j][0]];
int l0 = -vec[j].back(), r0 = -vec[j][0];
int l1 = l - tmp, r1 = r - tmp;
l0 = max(l0, l1), r0 = min(r0, r1);
res += max(0, r0 - l0 + 1);
}
cout << res << '\n';
}
}
Compilation message
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < vec.size(); ++j) {
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1083 ms |
13528 KB |
Output is correct |
2 |
Correct |
1047 ms |
13584 KB |
Output is correct |
3 |
Correct |
1057 ms |
13584 KB |
Output is correct |
4 |
Correct |
1078 ms |
13584 KB |
Output is correct |
5 |
Correct |
1222 ms |
13584 KB |
Output is correct |
6 |
Correct |
1204 ms |
13584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
13584 KB |
Output is correct |
2 |
Correct |
4 ms |
13584 KB |
Output is correct |
3 |
Correct |
4 ms |
13584 KB |
Output is correct |
4 |
Correct |
4 ms |
13584 KB |
Output is correct |
5 |
Correct |
5 ms |
13584 KB |
Output is correct |
6 |
Correct |
4 ms |
13584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1083 ms |
13528 KB |
Output is correct |
2 |
Correct |
1047 ms |
13584 KB |
Output is correct |
3 |
Correct |
1057 ms |
13584 KB |
Output is correct |
4 |
Correct |
1078 ms |
13584 KB |
Output is correct |
5 |
Correct |
1222 ms |
13584 KB |
Output is correct |
6 |
Correct |
1204 ms |
13584 KB |
Output is correct |
7 |
Correct |
4 ms |
13584 KB |
Output is correct |
8 |
Correct |
4 ms |
13584 KB |
Output is correct |
9 |
Correct |
4 ms |
13584 KB |
Output is correct |
10 |
Correct |
4 ms |
13584 KB |
Output is correct |
11 |
Correct |
5 ms |
13584 KB |
Output is correct |
12 |
Correct |
4 ms |
13584 KB |
Output is correct |
13 |
Correct |
1092 ms |
13584 KB |
Output is correct |
14 |
Correct |
1141 ms |
13584 KB |
Output is correct |
15 |
Correct |
1053 ms |
13584 KB |
Output is correct |
16 |
Correct |
1160 ms |
13584 KB |
Output is correct |
17 |
Correct |
1326 ms |
13584 KB |
Output is correct |
18 |
Correct |
1261 ms |
13584 KB |
Output is correct |
19 |
Correct |
1291 ms |
13584 KB |
Output is correct |
20 |
Correct |
1316 ms |
13584 KB |
Output is correct |
21 |
Correct |
1295 ms |
13584 KB |
Output is correct |
22 |
Correct |
1257 ms |
13584 KB |
Output is correct |
23 |
Correct |
1315 ms |
13584 KB |
Output is correct |
24 |
Correct |
1351 ms |
13584 KB |
Output is correct |
25 |
Correct |
1072 ms |
13584 KB |
Output is correct |
26 |
Correct |
1080 ms |
13584 KB |
Output is correct |
27 |
Correct |
1288 ms |
13584 KB |
Output is correct |
28 |
Correct |
1351 ms |
13584 KB |
Output is correct |
29 |
Correct |
1384 ms |
13584 KB |
Output is correct |
30 |
Correct |
1310 ms |
13584 KB |
Output is correct |
31 |
Correct |
1298 ms |
13584 KB |
Output is correct |
32 |
Correct |
1082 ms |
13584 KB |
Output is correct |
33 |
Correct |
2 ms |
13584 KB |
Output is correct |