답안 #775030

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775030 2023-07-06T07:00:33 Z Thanhs Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
917 ms 11124 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef stack<ll> sll;
typedef queue<ll> qll;
typedef deque<ll> dll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
 
// #define endl '\n'
#define pb push_back
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define BACK(i,a,b) for(int i = a; i >= b; i--)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define bp __builtin_popcountll
#define gcd __gcd
#define bit(i,n) ((n>>i)&1)
#define setmin(x,y) x=min((x),(y))
#define setmax(x,y) x=max((x),(y))
 
const int MAXN = (5e5)+5;
// const ll SQRT = 4;
const long long inf = 1e18;
const long long MOD = 1e9+7;

ll n,q,s[MAXN],d[MAXN],f[MAXN];

signed main()
{
	fastIO
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	cin>>n>>q;
	FOR(i,1,n) cin>>d[i];
	f[0]=1;
	FOR(i,1,n) f[i]=int((d[i]+f[i-1]-1)/f[i-1])*f[i-1];
	while(q--)
	{
		int t,l,r,up,m;
		cin>>t>>l>>r;
		if(t<l) {cout<<0<<endl; continue;}
		int lx=0,rx=n+1;
		while(lx<rx-1)
		{
			m=lx+rx>>1;
			if(-m+(t/f[m])*f[m]<l) rx=m;
			else lx=m; 
		}
		up=lx;
		lx=-1,rx=n;
		while(lx<rx-1)
		{
			m=lx+rx>>1;
			if(-m+(t/f[m])*f[m]>r) lx=m;
			else rx=m; 
		}
		cout<<up-rx+1<<endl;
	}
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:53:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   53 |    m=lx+rx>>1;
      |      ~~^~~
worst_reporter3.cpp:61:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   61 |    m=lx+rx>>1;
      |      ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 917 ms 11124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 917 ms 11124 KB Output isn't correct
2 Halted 0 ms 0 KB -