제출 #49355

#제출 시각아이디문제언어결과실행 시간메모리
49355gs13068Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
847 ms106684 KiB
#include <cstdio>

int n;
int a[500005];

inline int f(int T, int X) {
	int L, R, M;
	L = 0;
	R = n + 1;
	while (L < R) {
		M = L + R >> 1;
		if (T / a[M] * a[M] - M >= X) L = M + 1;
		else R = M;
	}
	return L;
}

int main() {
	int i, j, k, m;
	scanf("%d%d", &n, &m);
	a[0] = 1;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] = ((a[i] - 1) / a[i - 1] + 1) * a[i - 1];
	}
	while (m--) {
		scanf("%d%d%d", &i, &j, &k);
		printf("%d\n", f(i, j) - f(i, k + 1));
	}
}

컴파일 시 표준 에러 (stderr) 메시지

worst_reporter3.cpp: In function 'int f(int, int)':
worst_reporter3.cpp:11:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   M = L + R >> 1;
       ~~^~~
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:20: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:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &i, &j, &k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...