# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47460 | 2018-05-03T09:31:41 Z | Talant | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 1751 ms | 95980 KB |
#include <bits/stdc++.h> #define mk make_pair #define sc second #define fr first #define pb emplace_back #define all(s) s.begin(), s.end() #define sz(s) ( (int)s.size() ) #define int long long using namespace std; const int inf = (int)1e9 + 7; const int N = (int)6e5 + 7; int n,q,d[N],a[N]; int t,L,R; int cnt; bool check (int x) { int o = floor(t / a[x]) * a[x] - x; if (L <= o) return true; return false; } bool f(int x) { int o = floor(t / a[x]) * a[x] - x; if (R >= o) return true; return false; } main () { scanf ("%lld%lld", &n,&q); for (int i = 1; i <= n; i ++) scanf ("%lld", &d[i]); for (int i = 1; i <= n; i ++) { if (i == 1) a[i] = d[i]; else { int l = 1,r = a[i - 1] + d[i] + 5; while (r - l > 1) { int m = (r + l) >> 1; int o = floor(m / a[i - 1]) * a[i - 1] - (i - 1); if (o >= d[i] + 1 + (-i)) r = m; else l = m; } int o = floor(l / a[i - 1]) * a[i - 1] - (i - 1); if (o >= d[i] + 1 + (-i)) r = l; a[i] = r; } } while (q --) { scanf ("%lld%lld%lld", &t,&L,&R); if (t < L) { puts("0"); continue; } int l = 1,r = n; while (r - l > 1) { int m = (r + l) >> 1; if (check(m)) l = m; else r = m; } if (check(r)) l = r; if (!check(l)) l = 0; if (l == 0 && t <= R) { puts("1"); continue; } if (l == 0) { puts("0"); continue; } int lo = 1,hi = l; while (hi - lo > 1) { int m = (hi + lo) >> 1; if (f(m)) hi = m; else lo = m; } if (!f(hi)) { puts("0"); continue; } if (f(lo)) hi = lo; if (L <= t && t <= R) printf("%lld\n", l - hi + 2); else printf("%lld\n", l - hi + 1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1614 ms | 11384 KB | Output is correct |
2 | Correct | 1634 ms | 11384 KB | Output is correct |
3 | Correct | 1457 ms | 11384 KB | Output is correct |
4 | Correct | 1304 ms | 11384 KB | Output is correct |
5 | Correct | 1675 ms | 11384 KB | Output is correct |
6 | Correct | 1725 ms | 11384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 11384 KB | Output is correct |
2 | Correct | 4 ms | 11384 KB | Output is correct |
3 | Correct | 2 ms | 11384 KB | Output is correct |
4 | Correct | 3 ms | 11384 KB | Output is correct |
5 | Correct | 3 ms | 11384 KB | Output is correct |
6 | Correct | 3 ms | 11384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1614 ms | 11384 KB | Output is correct |
2 | Correct | 1634 ms | 11384 KB | Output is correct |
3 | Correct | 1457 ms | 11384 KB | Output is correct |
4 | Correct | 1304 ms | 11384 KB | Output is correct |
5 | Correct | 1675 ms | 11384 KB | Output is correct |
6 | Correct | 1725 ms | 11384 KB | Output is correct |
7 | Correct | 22 ms | 11384 KB | Output is correct |
8 | Correct | 4 ms | 11384 KB | Output is correct |
9 | Correct | 2 ms | 11384 KB | Output is correct |
10 | Correct | 3 ms | 11384 KB | Output is correct |
11 | Correct | 3 ms | 11384 KB | Output is correct |
12 | Correct | 3 ms | 11384 KB | Output is correct |
13 | Correct | 1119 ms | 11384 KB | Output is correct |
14 | Correct | 1155 ms | 26140 KB | Output is correct |
15 | Correct | 1020 ms | 41280 KB | Output is correct |
16 | Correct | 1084 ms | 57064 KB | Output is correct |
17 | Correct | 1554 ms | 76968 KB | Output is correct |
18 | Correct | 1499 ms | 95344 KB | Output is correct |
19 | Correct | 1396 ms | 95344 KB | Output is correct |
20 | Correct | 1379 ms | 95468 KB | Output is correct |
21 | Correct | 1443 ms | 95468 KB | Output is correct |
22 | Correct | 1355 ms | 95468 KB | Output is correct |
23 | Correct | 1751 ms | 95468 KB | Output is correct |
24 | Correct | 1745 ms | 95504 KB | Output is correct |
25 | Correct | 1443 ms | 95904 KB | Output is correct |
26 | Correct | 1371 ms | 95980 KB | Output is correct |
27 | Correct | 1392 ms | 95980 KB | Output is correct |
28 | Correct | 1535 ms | 95980 KB | Output is correct |
29 | Correct | 1500 ms | 95980 KB | Output is correct |
30 | Correct | 1584 ms | 95980 KB | Output is correct |
31 | Correct | 1407 ms | 95980 KB | Output is correct |
32 | Correct | 1216 ms | 95980 KB | Output is correct |
33 | Correct | 3 ms | 95980 KB | Output is correct |