답안 #379270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379270 2021-03-17T19:26:56 Z nafis_shifat Worst Reporter 3 (JOI18_worst_reporter3) C++14
0 / 100
610 ms 13292 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
int main() {
	int n,q;
	cin >> n >> q;

	ll d[n + 1];
	for(int i = 1; i <= n; i++) scanf("%lld",&d[i]);

	ll jump[n + 2];
    jump[0] = 1;

    for(int i = 1; i <= n; i++) {
    	jump[i] = jump[i - 1] * ((d[i] + jump[i - 1] - 1) / jump[i - 1]);
    	
    }


	while(q--) {
		ll t,l,r;
		scanf("%d%d%d",&t,&l,&r);
		int lo = 0;
		int hi  = n;
		int upb = 1,lwb = -1;

		while(lo <= hi) {
			int mid = lo + hi >> 1;
			ll x = t / jump[mid];
			ll p = -mid + x * jump[mid];
			if(p <= r) {
				upb = mid;
				hi = mid - 1;
			} else {
				lo = mid + 1;
			}
		}


		lo = 0;
		hi = n;
		while(lo <= hi) {
			int mid = lo + hi >> 1;
			ll x = t / jump[mid];
			ll p = -mid + x * jump[mid];
			if(p >= l) {
				lwb = mid;
				lo = mid + 1;
			} else {
				hi = mid - 1;
			}
		}
		int ans;
		if(lwb < upb) ans = 0;
		else ans = lwb - upb + 1;

		printf("%d\n",ans );
	}
	
}

Compilation message

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:25:11: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   25 |   scanf("%d%d%d",&t,&l,&r);
      |          ~^      ~~
      |           |      |
      |           int*   long long int*
      |          %lld
worst_reporter3.cpp:25:13: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   25 |   scanf("%d%d%d",&t,&l,&r);
      |            ~^       ~~
      |             |       |
      |             int*    long long int*
      |            %lld
worst_reporter3.cpp:25:15: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   25 |   scanf("%d%d%d",&t,&l,&r);
      |              ~^        ~~
      |               |        |
      |               int*     long long int*
      |              %lld
worst_reporter3.cpp:31:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |    int mid = lo + hi >> 1;
      |              ~~~^~~~
worst_reporter3.cpp:46:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |    int mid = lo + hi >> 1;
      |              ~~~^~~~
worst_reporter3.cpp:12:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  for(int i = 1; i <= n; i++) scanf("%lld",&d[i]);
      |                              ~~~~~^~~~~~~~~~~~~~
worst_reporter3.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   scanf("%d%d%d",&t,&l,&r);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 610 ms 13292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 610 ms 13292 KB Output isn't correct
2 Halted 0 ms 0 KB -