# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
220205 | patrikpavic2 | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 15 ms | 2304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstring>
#include <vector>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 500;
ll D[N];
int n, q;
int kolko(ll T,ll L,ll R){
ll tren = T;
int ans = 0;
//printf("TIME = %lld\n", T);
for(int i = 0;i <= n;i++){
//printf("POS[ %d ] = %lld\n", i, tren * D[i] - i);
if(L <= tren * D[i] - i && tren * D[i] - i <= R)
ans++;
if(i != n)
tren = tren / (D[i + 1] / D[i]);
if(!tren) break;
}
return ans;
}
int main(){
scanf("%d%d", &n, &q);
D[0] = 1;
for(int i = 1;i <= n;i++){
scanf("%lld", D + i);
if(D[i] < D[i - 1])
D[i] = D[i - 1];
else if(D[i] % D[i - 1])
D[i] += D[i - 1] - D[i] % D[i - 1];
}
for(;q--;){
ll A, B, C; scanf("%lld%lld%lld", &A, &B, &C);
printf("%d\n", kolko(A, B, C));
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |