Submission #878055

# Submission time Handle Problem Language Result Execution time Memory
878055 2023-11-24T03:51:20 Z NeroZein Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
442 ms 25604 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<long long> a(n); 
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] < a[i - 1]) {
      a[i] = a[i - 1];
    } else {
      a[i] = ((a[i] + a[i - 1] - 1) / a[i - 1]) * a[i - 1];
    }
  }
  while (q--) {
    int t, l, r;
    cin >> t >> l >> r;
    int ans = t >= l && t <= r;
    int lo = -1, hi = n - 1; 
    while (lo < hi) {
      int mid = (lo + hi + 1) / 2;
      long long p = (long long) t / a[mid] * a[mid] - mid - 1; 
      if (p >= l) {
        lo = mid;
      } else {
        hi = mid - 1; 
      }
    }
    int lo2 = 0, hi2 = n;
    while (lo2 < hi2) {
      int mid = (lo2 + hi2) / 2; 
      long long p = (long long) t / a[mid] * a[mid] - mid - 1; 
      if (p <= r) {
        hi2 = mid; 
      } else {
        lo2 = mid + 1; 
      }
    }
    cout << ans + (hi - lo2 + 1) << '\n'; 
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 436 ms 21604 KB Output is correct
2 Correct 442 ms 22612 KB Output is correct
3 Correct 434 ms 22608 KB Output is correct
4 Correct 440 ms 22880 KB Output is correct
5 Correct 433 ms 22824 KB Output is correct
6 Correct 433 ms 22744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 464 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 436 ms 21604 KB Output is correct
2 Correct 442 ms 22612 KB Output is correct
3 Correct 434 ms 22608 KB Output is correct
4 Correct 440 ms 22880 KB Output is correct
5 Correct 433 ms 22824 KB Output is correct
6 Correct 433 ms 22744 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 246 ms 21184 KB Output is correct
14 Correct 253 ms 21840 KB Output is correct
15 Correct 245 ms 20488 KB Output is correct
16 Correct 247 ms 21072 KB Output is correct
17 Correct 324 ms 25428 KB Output is correct
18 Correct 322 ms 25172 KB Output is correct
19 Correct 326 ms 25300 KB Output is correct
20 Correct 322 ms 25360 KB Output is correct
21 Correct 322 ms 25172 KB Output is correct
22 Correct 329 ms 25420 KB Output is correct
23 Correct 320 ms 25168 KB Output is correct
24 Correct 324 ms 25604 KB Output is correct
25 Correct 434 ms 22640 KB Output is correct
26 Correct 437 ms 22612 KB Output is correct
27 Correct 365 ms 24980 KB Output is correct
28 Correct 351 ms 25104 KB Output is correct
29 Correct 360 ms 25028 KB Output is correct
30 Correct 359 ms 24916 KB Output is correct
31 Correct 362 ms 25096 KB Output is correct
32 Correct 346 ms 21392 KB Output is correct
33 Correct 0 ms 348 KB Output is correct