Submission #774998

# Submission time Handle Problem Language Result Execution time Memory
774998 2023-07-06T06:37:51 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
472 ms 11164 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define gcd __gcd
#define endl '\n'
const int N=500050,M=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

ll n, q, d[N], u[N], t, l, r;

ll pos(ll i, ll t){return t/u[i]*u[i]-i;}

ll lower(ll t, ll x){
	ll l=-1, r=n+1;
	while(r-l>1){
		ll m=l+r>>1;
		if(pos(m, t)<=x) r=m;
		else l=m;
	}
	return r;
}

ll upper(ll t, ll x){
	ll l=-1, r=n+1;
	while(r-l>1){
		ll m=l+r>>1;
		if(pos(m, t)>=x) l=m;
		else r=m;
	}
	return l;
}

signed main(){
	ios_base::sync_with_stdio(NULL); 
	cin.tie(nullptr); cout.tie(nullptr);
	cin>>n>>q;
	for(ll i=1; i<=n; ++i) cin>>d[i];
	u[0]=1;
	for(ll i=1; i<=n; ++i){
		ll need=(d[i]+u[i-1]-1)/u[i-1];
		u[i]=need*u[i-1];
		// cout<<u[i]<<endl;
	}
	while(q--){
		cin>>t>>l>>r;
		ll up=upper(t, l);
		ll lo=lower(t, r);
		cout<<up-lo+1<<endl;
		// cout<<lo<<" "<<up<<endl;
	}
    return 0;
}

Compilation message

worst_reporter3.cpp: In function 'll lower(ll, ll)':
worst_reporter3.cpp:20:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |   ll m=l+r>>1;
      |        ~^~
worst_reporter3.cpp: In function 'll upper(ll, ll)':
worst_reporter3.cpp:30:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |   ll m=l+r>>1;
      |        ~^~
# Verdict Execution time Memory Grader output
1 Correct 429 ms 11144 KB Output is correct
2 Correct 472 ms 11128 KB Output is correct
3 Correct 467 ms 11144 KB Output is correct
4 Correct 454 ms 11080 KB Output is correct
5 Correct 447 ms 11084 KB Output is correct
6 Correct 440 ms 11136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 429 ms 11144 KB Output is correct
2 Correct 472 ms 11128 KB Output is correct
3 Correct 467 ms 11144 KB Output is correct
4 Correct 454 ms 11080 KB Output is correct
5 Correct 447 ms 11084 KB Output is correct
6 Correct 440 ms 11136 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 297 ms 9132 KB Output is correct
14 Correct 304 ms 9072 KB Output is correct
15 Correct 278 ms 9220 KB Output is correct
16 Correct 314 ms 9032 KB Output is correct
17 Correct 328 ms 10460 KB Output is correct
18 Correct 347 ms 10568 KB Output is correct
19 Correct 344 ms 10452 KB Output is correct
20 Correct 350 ms 10600 KB Output is correct
21 Correct 350 ms 10492 KB Output is correct
22 Correct 330 ms 10436 KB Output is correct
23 Correct 329 ms 10552 KB Output is correct
24 Correct 340 ms 10520 KB Output is correct
25 Correct 450 ms 11164 KB Output is correct
26 Correct 423 ms 11068 KB Output is correct
27 Correct 391 ms 10920 KB Output is correct
28 Correct 356 ms 10876 KB Output is correct
29 Correct 352 ms 10828 KB Output is correct
30 Correct 367 ms 10984 KB Output is correct
31 Correct 377 ms 10816 KB Output is correct
32 Correct 355 ms 10648 KB Output is correct
33 Correct 0 ms 212 KB Output is correct