#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q; cin>>n>>q;
vector<int> d(n + 1);
for (int i = 1; i <= n; i++){
cin>>d[i];
}
vector<int> k(n + 1);
k[1] = d[1];
for (int i = 2; i <= n; i++){
k[i] = ceil(1.0 * d[i] / k[i - 1]) * k[i - 1];
}
// x[i] = t * k[i] - i, t >= 0
for (int i = 1; i <= q; i++){
int t, l, r; cin>>t>>l>>r;
vector<int> x(n + 1);
int p = t - 1;
for (int j = 1; j <= n; j++){
int f = (p + j) / k[j];
x[j] = f * k[j] - j;
p = x[j] - 1;
}
int out = (l <= t && t <= r);
for (int j = 1; j <= n; j++){
out += (l <= x[j] && x[j] <= r);
}
cout<<out<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2064 ms |
7396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
344 KB |
Output is correct |
2 |
Correct |
7 ms |
344 KB |
Output is correct |
3 |
Correct |
7 ms |
484 KB |
Output is correct |
4 |
Correct |
6 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
6 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2064 ms |
7396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |