Submission #43976

# Submission time Handle Problem Language Result Execution time Memory
43976 2018-03-29T02:27:34 Z wzy Worst Reporter 3 (JOI18_worst_reporter3) C++11
100 / 100
1714 ms 11692 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n , q;	
int d[1000000];
int x[1000000];
int read(){
	char c;
	int a = 0;
	while(!(c >= '0' && c <= '9')) c = getchar();
	while(c >= '0' && c<='9'){
		a = 10*a + (c - '0');
		c =getchar();
	}
	return a;
}

int cima(int i , int j){
	if(i%j) return i/j + 1;
	else return i/j;
}


int32_t main(){
	n = read() , q  =read();
	for(int i = 1 ; i <= n; i++) d[i] = read();
	x[1] = d[1];
	for(int i = 2 ; i <= n; i++){
		x[i] = (x[i-1]) * (cima(d[i] , x[i-1]));
	}
	while(q--){
		int l , r ,t; 
		t = read();
		int def = 0;
		l = read() , r = read();
		int ll = 1 , rr = n;
		int ansj = n+1;
		if(l <= t && t <= r) def++;
		while(ll<=rr) {
			int mid = (ll+rr)/2;
			int p = t / x[mid];
			if(p*x[mid] - mid < l){
				ansj  = mid;
				rr = mid - 1;
			}
			else ll = mid + 1;
		}
		int ansj2 =0;
		ll = 1 , rr = n;
		while(ll<=rr){
			int mid = (ll+rr)/2;
			int p = t/x[mid];
			if(p*x[mid] - mid > r){
				ansj2 = mid ;
				ll = mid + 1;
			}
			else rr = mid - 1;
		}
		 def += n;
		if(ansj2) def -= ansj2;
		if(ansj != (n + 1)){
			def -= (n - ansj + 1);
		}
		cout<<def<<endl;
	}
}

Compilation message

worst_reporter3.cpp: In function 'long long int read()':
worst_reporter3.cpp:10:8: warning: 'c' is used uninitialized in this function [-Wuninitialized]
  while(!(c >= '0' && c <= '9')) c = getchar();
        ^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1615 ms 11356 KB Output is correct
2 Correct 1570 ms 11356 KB Output is correct
3 Correct 1567 ms 11428 KB Output is correct
4 Correct 1556 ms 11428 KB Output is correct
5 Correct 1602 ms 11428 KB Output is correct
6 Correct 1592 ms 11428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 11428 KB Output is correct
2 Correct 4 ms 11428 KB Output is correct
3 Correct 4 ms 11428 KB Output is correct
4 Correct 4 ms 11428 KB Output is correct
5 Correct 4 ms 11428 KB Output is correct
6 Correct 4 ms 11428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1615 ms 11356 KB Output is correct
2 Correct 1570 ms 11356 KB Output is correct
3 Correct 1567 ms 11428 KB Output is correct
4 Correct 1556 ms 11428 KB Output is correct
5 Correct 1602 ms 11428 KB Output is correct
6 Correct 1592 ms 11428 KB Output is correct
7 Correct 4 ms 11428 KB Output is correct
8 Correct 4 ms 11428 KB Output is correct
9 Correct 4 ms 11428 KB Output is correct
10 Correct 4 ms 11428 KB Output is correct
11 Correct 4 ms 11428 KB Output is correct
12 Correct 4 ms 11428 KB Output is correct
13 Correct 1172 ms 11428 KB Output is correct
14 Correct 1168 ms 11428 KB Output is correct
15 Correct 1132 ms 11428 KB Output is correct
16 Correct 1165 ms 11428 KB Output is correct
17 Correct 1399 ms 11428 KB Output is correct
18 Correct 1397 ms 11428 KB Output is correct
19 Correct 1391 ms 11428 KB Output is correct
20 Correct 1345 ms 11428 KB Output is correct
21 Correct 1345 ms 11428 KB Output is correct
22 Correct 1714 ms 11428 KB Output is correct
23 Correct 1422 ms 11428 KB Output is correct
24 Correct 1411 ms 11428 KB Output is correct
25 Correct 1605 ms 11692 KB Output is correct
26 Correct 1627 ms 11692 KB Output is correct
27 Correct 1429 ms 11692 KB Output is correct
28 Correct 1408 ms 11692 KB Output is correct
29 Correct 1515 ms 11692 KB Output is correct
30 Correct 1446 ms 11692 KB Output is correct
31 Correct 1426 ms 11692 KB Output is correct
32 Correct 1355 ms 11692 KB Output is correct
33 Correct 2 ms 11692 KB Output is correct