Submission #919713

#TimeUsernameProblemLanguageResultExecution timeMemory
919713eggx50000Worst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
481 ms25424 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...