답안 #120124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120124 2019-06-23T13:29:16 Z Mamnoon_Siam Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
664 ms 25416 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 5e5 + 5;
int n, m;
int d[maxn], f[maxn];

int where(int id, int T) {
	return int(T / f[id]) * f[id] - id;
}
int count(int lim, int T) {
	int lo = 1, hi = n, mid, opt = n + 1;
	while(lo <= hi) {
		mid = lo + hi >> 1;
		if(where(mid, T) <= lim)
			opt = mid, hi = mid - 1;
		else lo = mid + 1;
	} return (n + 1) - opt;
}
int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	scanf("%d %d", &n, &m);
	d[0] = f[0] = 1;
	for(int i = 1; i <= n; i++) {
		scanf("%d", d + i);
		f[i] = f[i - 1] * ((d[i] - 1) / f[i - 1] + 1);
	}
	while(m--) {
		int l, r, T;
		scanf("%d %d %d", &T, &l, &r);
		printf("%d\n", count(r, T) - count(l - 1, T) + (l <= T and T <= r));
	}
	return 0;
}

Compilation message

worst_reporter3.cpp: In function 'int count(int, int)':
worst_reporter3.cpp:14:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   mid = lo + hi >> 1;
         ~~~^~~~
worst_reporter3.cpp: In function 'int main(int, const char**)':
worst_reporter3.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
worst_reporter3.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", d + i);
   ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &T, &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 558 ms 22668 KB Output is correct
2 Correct 566 ms 22648 KB Output is correct
3 Correct 570 ms 22768 KB Output is correct
4 Correct 559 ms 22776 KB Output is correct
5 Correct 569 ms 22808 KB Output is correct
6 Correct 575 ms 22648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 558 ms 22668 KB Output is correct
2 Correct 566 ms 22648 KB Output is correct
3 Correct 570 ms 22768 KB Output is correct
4 Correct 559 ms 22776 KB Output is correct
5 Correct 569 ms 22808 KB Output is correct
6 Correct 575 ms 22648 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 378 ms 21220 KB Output is correct
14 Correct 379 ms 21880 KB Output is correct
15 Correct 374 ms 20472 KB Output is correct
16 Correct 387 ms 20984 KB Output is correct
17 Correct 496 ms 25180 KB Output is correct
18 Correct 480 ms 25360 KB Output is correct
19 Correct 486 ms 25324 KB Output is correct
20 Correct 502 ms 25228 KB Output is correct
21 Correct 558 ms 25276 KB Output is correct
22 Correct 496 ms 25416 KB Output is correct
23 Correct 498 ms 25208 KB Output is correct
24 Correct 501 ms 25340 KB Output is correct
25 Correct 596 ms 22732 KB Output is correct
26 Correct 604 ms 22904 KB Output is correct
27 Correct 513 ms 24952 KB Output is correct
28 Correct 494 ms 25208 KB Output is correct
29 Correct 664 ms 24952 KB Output is correct
30 Correct 541 ms 25064 KB Output is correct
31 Correct 509 ms 25120 KB Output is correct
32 Correct 445 ms 21240 KB Output is correct
33 Correct 2 ms 384 KB Output is correct