Submission #514758

# Submission time Handle Problem Language Result Execution time Memory
514758 2022-01-18T12:55:11 Z couplefire Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
697 ms 29224 KB
#include <bits/stdc++.h>
#define long long long
using namespace std;
 
const int N = 5e5+5;
 
int n, q;
long s[N], t[N];
 
int cnt(long T, long R) {
    int l = 0, r = n;
    while(l < r) {
        int mid = (l + r) >> 1;
        if(s[mid] * (T / t[mid]) - mid <= R) r = mid;
        else l = mid + 1;
    }
    if(s[r] * (T / t[r]) - r <= R) return n + 1 - r;
    else return 0;
}
 
int main() {
    scanf("%d %d", &n, &q);
    s[0] = t[0] = 1;
    for(int i = 1, d; i <= n; i++) {
        scanf("%d", &d);
        long k = d / s[i-1] + (d % s[i-1] != 0);
        s[i] = s[i-1] * k, t[i] = t[i-1] * k;
    }
    for(int i = 1, t, l, r; i <= q; i++) {
        scanf("%d %d %d", &t, &l, &r);
        printf("%d\n", cnt(t, r) - cnt(t, l-1));
    }
 
    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d", &d);
      |         ~~~~~^~~~~~~~~~
worst_reporter3.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d %d %d", &t, &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 616 ms 26680 KB Output is correct
2 Correct 635 ms 26580 KB Output is correct
3 Correct 639 ms 26612 KB Output is correct
4 Correct 697 ms 26596 KB Output is correct
5 Correct 651 ms 26548 KB Output is correct
6 Correct 637 ms 26496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 2 ms 312 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 616 ms 26680 KB Output is correct
2 Correct 635 ms 26580 KB Output is correct
3 Correct 639 ms 26612 KB Output is correct
4 Correct 697 ms 26596 KB Output is correct
5 Correct 651 ms 26548 KB Output is correct
6 Correct 637 ms 26496 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 2 ms 312 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 403 ms 24976 KB Output is correct
14 Correct 458 ms 25668 KB Output is correct
15 Correct 471 ms 24244 KB Output is correct
16 Correct 467 ms 24768 KB Output is correct
17 Correct 609 ms 29152 KB Output is correct
18 Correct 572 ms 29144 KB Output is correct
19 Correct 550 ms 29120 KB Output is correct
20 Correct 446 ms 29124 KB Output is correct
21 Correct 443 ms 29180 KB Output is correct
22 Correct 531 ms 29176 KB Output is correct
23 Correct 503 ms 29080 KB Output is correct
24 Correct 464 ms 29208 KB Output is correct
25 Correct 654 ms 26572 KB Output is correct
26 Correct 653 ms 26540 KB Output is correct
27 Correct 507 ms 28800 KB Output is correct
28 Correct 481 ms 29224 KB Output is correct
29 Correct 512 ms 28540 KB Output is correct
30 Correct 505 ms 28692 KB Output is correct
31 Correct 501 ms 28844 KB Output is correct
32 Correct 467 ms 25104 KB Output is correct
33 Correct 1 ms 204 KB Output is correct