# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44055 | 2018-03-29T13:05:00 Z | zadrga | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 1097 ms | 11436 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define fi first #define se second #define INF (1LL << 55) #define MOD (1000 * 1000 * 1000 + 7) #define maxn 500111 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; ll d[maxn], f[maxn]; ll CEIL(ll a, ll b){ return (a + b - 1) / b; } ll find(ll t, ll mid){ if(mid == 0){ return -1234; } ll x = f[mid]; ll cnt = t / x; ll pos = cnt * x - mid; return pos; } int main(){ int n, q; scanf("%d%d", &n, &q); for(int i = 1; i <= n; i++) scanf("%lld", d + i); f[1] = d[1]; for(int i = 2; i <= n; i++) f[i] = f[i - 1] * CEIL(d[i], f[i - 1]); while(q--){ ll t, i, j; scanf("%lld%lld%lld", &t, &i, &j); ll dod = 0; if(i <= t && t <= j) dod = 1; ll l = 1, d = n, mid, ans1 = 0, ans2 = 0; while(l <= d){ mid = (l + d) / 2; ll pos = find(t, mid); if(pos >= i){ l = mid + 1; ans1 = mid; } else d = mid - 1; } l = 1; d = n; while(l <= d){ mid = (l + d) / 2; ll pos = find(t, mid); if(pos <= j){ d = mid - 1; ans2 = mid; } else l = mid + 1; } ll all = 0; if(find(t, ans2) < i || find(t, ans1) > j || ans1 < ans2) all = 0; else all = ans1 - ans2 + 1; printf("%lld\n", all + dod); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1080 ms | 11128 KB | Output is correct |
2 | Correct | 1097 ms | 11360 KB | Output is correct |
3 | Correct | 1000 ms | 11360 KB | Output is correct |
4 | Correct | 1014 ms | 11360 KB | Output is correct |
5 | Correct | 1006 ms | 11360 KB | Output is correct |
6 | Correct | 1047 ms | 11360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 11360 KB | Output is correct |
2 | Correct | 3 ms | 11360 KB | Output is correct |
3 | Correct | 3 ms | 11360 KB | Output is correct |
4 | Correct | 3 ms | 11360 KB | Output is correct |
5 | Correct | 3 ms | 11360 KB | Output is correct |
6 | Correct | 3 ms | 11360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1080 ms | 11128 KB | Output is correct |
2 | Correct | 1097 ms | 11360 KB | Output is correct |
3 | Correct | 1000 ms | 11360 KB | Output is correct |
4 | Correct | 1014 ms | 11360 KB | Output is correct |
5 | Correct | 1006 ms | 11360 KB | Output is correct |
6 | Correct | 1047 ms | 11360 KB | Output is correct |
7 | Correct | 3 ms | 11360 KB | Output is correct |
8 | Correct | 3 ms | 11360 KB | Output is correct |
9 | Correct | 3 ms | 11360 KB | Output is correct |
10 | Correct | 3 ms | 11360 KB | Output is correct |
11 | Correct | 3 ms | 11360 KB | Output is correct |
12 | Correct | 3 ms | 11360 KB | Output is correct |
13 | Correct | 631 ms | 11360 KB | Output is correct |
14 | Correct | 629 ms | 11360 KB | Output is correct |
15 | Correct | 630 ms | 11360 KB | Output is correct |
16 | Correct | 622 ms | 11360 KB | Output is correct |
17 | Correct | 759 ms | 11360 KB | Output is correct |
18 | Correct | 776 ms | 11360 KB | Output is correct |
19 | Correct | 776 ms | 11360 KB | Output is correct |
20 | Correct | 911 ms | 11360 KB | Output is correct |
21 | Correct | 785 ms | 11360 KB | Output is correct |
22 | Correct | 842 ms | 11360 KB | Output is correct |
23 | Correct | 792 ms | 11360 KB | Output is correct |
24 | Correct | 794 ms | 11360 KB | Output is correct |
25 | Correct | 959 ms | 11400 KB | Output is correct |
26 | Correct | 1035 ms | 11436 KB | Output is correct |
27 | Correct | 894 ms | 11436 KB | Output is correct |
28 | Correct | 832 ms | 11436 KB | Output is correct |
29 | Correct | 796 ms | 11436 KB | Output is correct |
30 | Correct | 911 ms | 11436 KB | Output is correct |
31 | Correct | 837 ms | 11436 KB | Output is correct |
32 | Correct | 756 ms | 11436 KB | Output is correct |
33 | Correct | 2 ms | 11436 KB | Output is correct |