Submission #919713

# Submission time Handle Problem Language Result Execution time Memory
919713 2024-02-01T14:18:58 Z eggx50000 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
481 ms 25424 KB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int n, q;
ll arr[500099], t, l, r;

ll f(ll t, ll v){
    int s = 0, e = n;
    while(s <= e){
        int mid = (s + e) / 2;
        if(-mid + t / arr[mid] * arr[mid] >= v) s = mid + 1;
        else e = mid - 1;
    }
    return e + 1;
}

int main()
{
    scanf("%d %d", &n, &q);
    arr[0] = 1;
    for(int i = 1; i <= n; i ++){
        scanf("%lld", arr + i);
        arr[i] = max(arr[i], arr[i - 1]);
        arr[i] = arr[i - 1] * ((arr[i - 1] + arr[i] - 1) / arr[i - 1]);
    }
    while(q --){
        scanf("%lld %lld %lld", &t, &l, &r);
        printf("%lld\n", f(t, l) - f(t, r + 1));
    }
    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%lld", arr + i);
      |         ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%lld %lld %lld", &t, &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 481 ms 22832 KB Output is correct
2 Correct 474 ms 22720 KB Output is correct
3 Correct 465 ms 22868 KB Output is correct
4 Correct 468 ms 22608 KB Output is correct
5 Correct 464 ms 22932 KB Output is correct
6 Correct 470 ms 22584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 481 ms 22832 KB Output is correct
2 Correct 474 ms 22720 KB Output is correct
3 Correct 465 ms 22868 KB Output is correct
4 Correct 468 ms 22608 KB Output is correct
5 Correct 464 ms 22932 KB Output is correct
6 Correct 470 ms 22584 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 297 ms 21068 KB Output is correct
14 Correct 292 ms 21796 KB Output is correct
15 Correct 287 ms 20560 KB Output is correct
16 Correct 300 ms 20916 KB Output is correct
17 Correct 357 ms 25164 KB Output is correct
18 Correct 363 ms 25168 KB Output is correct
19 Correct 372 ms 25424 KB Output is correct
20 Correct 350 ms 25164 KB Output is correct
21 Correct 356 ms 25168 KB Output is correct
22 Correct 361 ms 25424 KB Output is correct
23 Correct 362 ms 25164 KB Output is correct
24 Correct 369 ms 25424 KB Output is correct
25 Correct 474 ms 22860 KB Output is correct
26 Correct 470 ms 22772 KB Output is correct
27 Correct 400 ms 24884 KB Output is correct
28 Correct 409 ms 25112 KB Output is correct
29 Correct 387 ms 24908 KB Output is correct
30 Correct 390 ms 24776 KB Output is correct
31 Correct 396 ms 25072 KB Output is correct
32 Correct 366 ms 21324 KB Output is correct
33 Correct 0 ms 344 KB Output is correct