이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <iomanip>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#define endl '\n'
#define X first
#define Y second
using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair<int, int> pii;
const int maxn = 5e5+10;
int D[maxn];
int T[maxn];
inline int get_at(int i, int t)
{
	return -i + ( (t/T[i]) * T[i] );
}
int n;
inline int bisect(int x, int t)
{
	int down = -1;
	int up = n+1;
	while(up-down > 1)
	{
		int mid = (up+down) / 2;
		if(get_at(mid, t) <= x)
			up = mid;
		else
			down = mid;
	}
	return up;
}
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q; cin >> n >> q;
	for(int i = 1; i <= n; i++)
		cin >> D[i];
	T[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		T[i] = ((D[i] + T[i-1] - 1) / T[i-1]) * T[i-1];
	}
	while(q--)
	{
		int t, l, r; cin >> t >> l >> r;
		int a = bisect(r, t);
		int b = bisect(l-1, t);
		cout << b-a << endl;
	}
	return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |