# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
62919 | kingpig9 | Worst Reporter 3 (JOI18_worst_reporter3) | C++11 | 1458 ms | 13728 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5e5 + 10;
const ll INF = 2e9;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
int N, Q;
ll P[MAXN];
int moo (ll t, ll x) {
int lo = 0, hi = N + 2; //how many are >= x?
while (hi - lo > 1) {
int mid = (lo + hi) / 2;
if (P[mid - 1] * (t / P[mid - 1]) - (mid - 1) >= x) {
lo = mid;
} else {
hi = mid;
}
}
return lo;
}
int main() {
scanf("%d %d", &N, &Q);
P[0] = 1;
for (int i = 1; i <= N; i++) {
ll d;
scanf("%lld", &d);
P[i] = ((d + P[i - 1] - 1) / P[i - 1]) * P[i - 1];
}
for (int qi = 0; qi < Q; qi++) {
ll t, lt, rt;
scanf("%lld %lld %lld", &t, <, &rt);
printf("%d\n", moo(t, lt) - moo(t, rt + 1));
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |