답안 #389929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
389929 2021-04-14T21:32:02 Z nikatamliani Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
16 ms 4264 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e5+10;
ll d[N], t[N];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	ll n, q;
	cin >> n >> q;
	for(int i = 1; i <= n; ++i) {
		cin >> d[i];
	}
	t[0] = 1;
	for(int i = 1; i <= n; ++i) {
		t[i] = (d[i]+t[i-1]-1) / t[i-1] * t[i-1];
	}
	auto coord = [&](ll x, ll time) -> ll {
		return -x + time / t[x] * t[x];
	};
	auto query = [&](ll x, ll t) -> ll {
		ll l = 0, r = n, ans = n+1;
		while(r >= l) {
			ll m = l + r >> 1;
			if(coord(m, t) <= x) {
				r = m - 1;
				ans = m;
			} else {
				l = m + 1;
			}
		}
		return n - ans + 1;
	};
	for(int i = 0; i < q; ++i) {
		ll t, l, r;
		cin >> t >> l >> r;
		cout << query(r, t) - query(l - 1, t) << '\n';
	}
}

Compilation message

worst_reporter3.cpp: In lambda function:
worst_reporter3.cpp:23:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |    ll m = l + r >> 1;
      |           ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 4264 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 4264 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -