Submission #469258

# Submission time Handle Problem Language Result Execution time Memory
469258 2021-08-31T09:20:00 Z keta_tsimakuridze Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
94 ms 10948 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 = 2e5 + 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(){
	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) << endl;
	}
 }

Compilation message

worst_reporter3.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 94 ms 10948 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 308 KB Output is correct
6 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 94 ms 10948 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -