답안 #469260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469260 2021-08-31T09:21:01 Z keta_tsimakuridze Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
698 ms 33160 KB
#include<bits/stdc++.h>
#define f first
#define s second
#define int long long
#define pii pair<int,int>
#define endl "\n"
using namespace std;
const int N = 5e5 + 5, inf = 1e15 + 7; // !
int t[N],v[N],d[N],n,q,L;
int get(int x,int T) {
	int l = 0, r = L,cnt = 0;
	while(l <= r) {
		int mid = (l + r) / 2; 
		if(-mid + T / t[mid] * v[mid] >= x) cnt = mid + 1, l = mid + 1;
		else r = mid - 1;
	}
	return cnt;
}
main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int q;
	cin >> n >> q;
	for(int i = 1; i <= n; i++) {
		cin >> d[i];
	}
	t[0] = v[0] = 1;
	L = 0;
	for(int i = 1; i <= n; i++) {
		t[i] = t[i - 1] * ((d[i] + v[i - 1] - 1) / v[i - 1]);
		if(t[i] > inf) {
			break;
		}
		L = i;
		v[i] = (d[i] + v[i - 1] - 1 ) / v[i - 1] * v[i - 1];
	}
	while(q--) {
		int l,r,t;
		cin >>t >>  l >> r;
		cout << get(l,t) - get(r + 1,t) << " ";
	}
 }

Compilation message

worst_reporter3.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 665 ms 15428 KB Output is correct
2 Correct 686 ms 30404 KB Output is correct
3 Correct 698 ms 30496 KB Output is correct
4 Correct 689 ms 30532 KB Output is correct
5 Correct 678 ms 30476 KB Output is correct
6 Correct 669 ms 30404 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 665 ms 15428 KB Output is correct
2 Correct 686 ms 30404 KB Output is correct
3 Correct 698 ms 30496 KB Output is correct
4 Correct 689 ms 30532 KB Output is correct
5 Correct 678 ms 30476 KB Output is correct
6 Correct 669 ms 30404 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 386 ms 28920 KB Output is correct
14 Correct 396 ms 29520 KB Output is correct
15 Correct 382 ms 28144 KB Output is correct
16 Correct 396 ms 28744 KB Output is correct
17 Correct 489 ms 33160 KB Output is correct
18 Correct 490 ms 32988 KB Output is correct
19 Correct 479 ms 33092 KB Output is correct
20 Correct 500 ms 32964 KB Output is correct
21 Correct 494 ms 33052 KB Output is correct
22 Correct 480 ms 32996 KB Output is correct
23 Correct 482 ms 32964 KB Output is correct
24 Correct 472 ms 33028 KB Output is correct
25 Correct 692 ms 30404 KB Output is correct
26 Correct 693 ms 30644 KB Output is correct
27 Correct 550 ms 32616 KB Output is correct
28 Correct 546 ms 33084 KB Output is correct
29 Correct 554 ms 32596 KB Output is correct
30 Correct 542 ms 32544 KB Output is correct
31 Correct 542 ms 32760 KB Output is correct
32 Correct 517 ms 29160 KB Output is correct
33 Correct 1 ms 332 KB Output is correct