#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5e5 + 1;
int d[MAX_N], per[MAX_N];
int higher( int x, int n ) {
return ((int)ceil( (double)n / x )) * x;
}
int lower( int x, int n ) {
return ((int)floor( (double)n / x )) * x;
}
int main() {
int n, q;
cin >> n >> q;
d[0] = 1;
for ( int i = 1; i <= n; i++ )
cin >> d[i];
int maxx = 1, pos = 0;
per[0] = 1;
for ( int i = 1; i <= n; i++ ) {
per[i] = higher( per[pos], d[i] );
if ( d[i] > maxx ) {
maxx = d[i];
pos = i;
}
}
while ( q-- ) {
int t, l, r, ans = 0;
cin >> t >> l >> r;
for ( int i = 0; i <= n; i++ ) {
int x = lower( per[i], t ) - i;
if ( l <= x && x <= r )
ans++;
}
cout << ans << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2050 ms |
5452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
212 KB |
Output is correct |
2 |
Correct |
5 ms |
316 KB |
Output is correct |
3 |
Correct |
5 ms |
320 KB |
Output is correct |
4 |
Correct |
5 ms |
340 KB |
Output is correct |
5 |
Correct |
5 ms |
340 KB |
Output is correct |
6 |
Correct |
6 ms |
316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2050 ms |
5452 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |