#include<bits/stdc++.h>
using namespace std;
/*
1o da fila: a cada d1 instantes, anda d1 pra direita
quando t/d1 * d1 >= d2, d2 gruda em d1
qtd[i] == qtd de movimentos que IOI-chan tem q andar pra eu andar
dist[i] == quanto eu ando por andada
qtd[1] = d1
dist[1] = d1
qtd[i] = ((di + dist[i-1] - 1)/dist[i-1]) * qtd[i];
dist[i] = (qtd[i] / qtd[i-1]) * dist[i-1];
*/
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n, q;
cin >> n >> q;
vector<int> d(n), qtd(n);
for(int i=0; i<n; i++){
cin >> d[i];
if(i) qtd[i] = ((d[i] + qtd[i-1] - 1)/qtd[i-1]) * qtd[i-1];
else qtd[i] = d[i];
}
while(q--){
int t, l, r;
cin >> t >> l >> r;
int ans = 0;
if(l <= t and t <= r) ans++;
for(int i=0; i<n; i++){
int pos = t / qtd[i] * qtd[i] - i - 1;
if(l <= pos and pos <= r) ans++;
}
cout << ans << "\n";
}
/*vector<int> pos = {0, -1, -2, -3};
vector<int> d = {1, 1, 5, 11};
vector<int> qtd(4), dist(4);
qtd[1] = dist[1] = d[1];
for(int i=2; i<4; i++){
//cout << qtd[i-1] << " " << dist[i-1] << "\n";
qtd[i] = ((d[i] + dist[i-1] - 1)/dist[i-1]) * qtd[i-1];
//dist[i] = (qtd[i] / qtd[i-1]) * dist[i-1];
}
for(int i=1; i<4; i++){
cout << i << " " << qtd[i] << " " << dist[i] << "\n";
}
int n = 50;
for(int t=1; t<=n; t++){
for(int j=0; j<4; j++){
if(j == 0) pos[j]++;
else if(pos[j-1] - pos[j] > d[j]) pos[j] = pos[j-1] - 1;
}
cout << "tempo " << t << ": " << pos[1] << " " << pos[2] << " " << pos[3] << "\n";
}*/
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2027 ms |
5360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
6 ms |
312 KB |
Output is correct |
4 |
Correct |
6 ms |
320 KB |
Output is correct |
5 |
Correct |
6 ms |
316 KB |
Output is correct |
6 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2027 ms |
5360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |