제출 #201872

#제출 시각아이디문제언어결과실행 시간메모리
201872EntityITWorst Reporter 3 (JOI18_worst_reporter3)C++14
19 / 100
649 ms21752 KiB
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafCLover

  int n, q; cin >> n >> q;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];

  vector<int> f(n); f[0] = d[0];
  for (int i = 1; i < sz(f); ++i) f[i] = (int)min( (LL)2e9, (LL)( (d[i] + f[i - 1] - 1) / f[i - 1]) * f[i - 1]);

  while (q--) {
    int t, l, r; cin >> t >> l >> r;

    int ans = (l <= t && t <= r);

    int L = 0, R = n;
    while (L < R) {
      int M = (L + R) >> 1;
      if (t - t % f[M] - (M + 1) <= r) R = M;
      else L = M + 1;
    }

    ans += -L;

    L = 0; R = n;
    while (L < R) {
      int M = (L + R) >> 1;
      if (t - t % f[M] - (M + 1) < l) R = M;
      else L = M + 1;
    }

    ans += L;

    cout << ans << '\n';
  }

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...