답안 #441874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441874 2021-07-06T13:02:45 Z dutch Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
787 ms 11332 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 2e9, MAXN = 5e5;

int n, q, d[MAXN], s[MAXN];

int search(int x, int p){
	int i = -1; p -= x;
	for(int j=1<<20; j/=2; )
		if(i+j < n && -i-j-x%s[i+j] > p) i += j;
	return i;
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> q;
	for(int i=0; i<n; ++i) cin >> d[i];

	fill(s, s+n, INF);
	s[0] = d[0];

	for(int i=1; i<n && s[i-1] < INF; ++i)
		s[i] = ((d[i] + s[i-1] - 1) / s[i-1]) * s[i-1];

	while(q--){
		int x, l, r; cin >> x >> l >> r;
		cout << search(x, l) - search(x, r+1) + (l <= x && x <= r) << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 639 ms 11248 KB Output is correct
2 Correct 651 ms 11228 KB Output is correct
3 Correct 676 ms 11204 KB Output is correct
4 Correct 683 ms 11232 KB Output is correct
5 Correct 657 ms 11244 KB Output is correct
6 Correct 668 ms 11332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 639 ms 11248 KB Output is correct
2 Correct 651 ms 11228 KB Output is correct
3 Correct 676 ms 11204 KB Output is correct
4 Correct 683 ms 11232 KB Output is correct
5 Correct 657 ms 11244 KB Output is correct
6 Correct 668 ms 11332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 457 ms 9248 KB Output is correct
14 Correct 440 ms 9212 KB Output is correct
15 Correct 437 ms 9196 KB Output is correct
16 Correct 432 ms 9156 KB Output is correct
17 Correct 526 ms 10480 KB Output is correct
18 Correct 515 ms 10600 KB Output is correct
19 Correct 520 ms 10424 KB Output is correct
20 Correct 512 ms 10544 KB Output is correct
21 Correct 515 ms 10728 KB Output is correct
22 Correct 527 ms 10708 KB Output is correct
23 Correct 527 ms 10548 KB Output is correct
24 Correct 530 ms 10532 KB Output is correct
25 Correct 787 ms 11232 KB Output is correct
26 Correct 665 ms 11280 KB Output is correct
27 Correct 569 ms 10948 KB Output is correct
28 Correct 552 ms 10832 KB Output is correct
29 Correct 567 ms 10856 KB Output is correct
30 Correct 564 ms 10988 KB Output is correct
31 Correct 557 ms 10880 KB Output is correct
32 Correct 555 ms 10764 KB Output is correct
33 Correct 1 ms 204 KB Output is correct