# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
627391 | 2022-08-12T14:17:46 Z | MilosMilutinovic | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 682 ms | 20656 KB |
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < (int)(n); i ++) #define rep1(i, n) for(int i = 1; i <= (int)(n); i ++) #define MP make_pair using namespace std; typedef long long LL; typedef pair<int, int> PII; int n, q, d[500005]; int calc(int i, int T) { int coeff = T / d[i]; return coeff * d[i] - i - 1; } int main() { scanf("%d%d", &n, &q); rep(i, n) scanf("%d", &d[i]); rep(i, n) { if(i == 0) continue; d[i] = d[i - 1] * ((d[i] + d[i - 1] - 1) / d[i - 1]); } while(q--) { int T, L, R; scanf("%d%d%d", &T, &L, &R); int l = -1, r = -1; { int low = 0, high = n - 1; while(low <= high) { int mid = low + high >> 1; if(calc(mid, T) <= R) l = mid, high = mid - 1; else low = mid + 1; } } { int low = 0, high = n - 1; while(low <= high) { int mid = low + high >> 1; if(calc(mid, T) >= L) r = mid, low = mid + 1; else high = mid - 1; } } int ans; if(l == -1 || calc(l, T) > R) ans = 0; else ans = r - l + 1; if(L <= T && T <= R) ans ++; printf("%d\n", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 579 ms | 20588 KB | Output is correct |
2 | Correct | 655 ms | 20624 KB | Output is correct |
3 | Correct | 682 ms | 20612 KB | Output is correct |
4 | Correct | 578 ms | 20656 KB | Output is correct |
5 | Correct | 580 ms | 20580 KB | Output is correct |
6 | Correct | 562 ms | 20636 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 2 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 2 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 579 ms | 20588 KB | Output is correct |
2 | Correct | 655 ms | 20624 KB | Output is correct |
3 | Correct | 682 ms | 20612 KB | Output is correct |
4 | Correct | 578 ms | 20656 KB | Output is correct |
5 | Correct | 580 ms | 20580 KB | Output is correct |
6 | Correct | 562 ms | 20636 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 2 ms | 212 KB | Output is correct |
13 | Runtime error | 61 ms | 9336 KB | Execution killed with signal 8 |
14 | Halted | 0 ms | 0 KB | - |