# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47450 | 2018-05-03T07:16:47 Z | Just_Solve_The_Problem | Worst Reporter 3 (JOI18_worst_reporter3) | C++11 | 552 ms | 9296 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define ll long long #define pii pair < int, int > #define fr first #define sc second #define mk make_pair #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() #define ok puts("ok"); #define whatis(x) cerr << #x << " = " << x << endl; #define pause system("pause"); #define random rand() ^ (rand() << 5) const int N = (int)5e5 + 7; const int inf = (int)1e9 + 7; int n, q; int d[N]; pii ar[N]; ll pos[N]; bool fl = 1; void solve1() { while (q--) { int t, l, r; scanf("%d %d %d", &t, &l, &r); int tl = -n + t; int tr = t; int ans = 0; if (tl <= l && r <= tr) { ans = r - l + 1; } else if (l <= tl && tr <= r) { ans = tr - tl + 1; } else if (tr >= l && l > tl) { ans = tr - l + 1; } else if (tl <= r && tr > r) { ans = r - tl + 1; } printf("%d\n", ans); } } void solve2() { while (q--) { int t, l, r; scanf("%d %d %d", &t, &l, &r); for (int i = 0; i <= n; i++) { pos[i] = t / ar[i].sc * ar[i].fr + (-i); } int ans = 0; for (int i = 0; i <= n; i++) { if (pos[i] >= l && pos[i] <= r) { ans++; } } printf("%d\n", ans); } } void solve3() { } main() { scanf("%d %d", &n, &q); ar[0] = {1, 1}; for (int i = 1; i <= n; i++) { scanf("%d", &d[i]); ar[i].sc = (d[i] + ar[i - 1].sc - 1) / ar[i - 1].sc * ar[i - 1].fr; ar[i].fr = (ar[i].sc / ar[i - 1].fr * ar[i - 1].sc + (-(i - 1))) - 1 - (-i); fl &= (d[i] == 1); } if (fl) { solve1(); } else if (n <= 10000) { solve2(); } else { solve3(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 407 ms | 9080 KB | Output is correct |
2 | Correct | 380 ms | 9204 KB | Output is correct |
3 | Correct | 387 ms | 9296 KB | Output is correct |
4 | Correct | 397 ms | 9296 KB | Output is correct |
5 | Correct | 421 ms | 9296 KB | Output is correct |
6 | Correct | 552 ms | 9296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 9296 KB | Output is correct |
2 | Correct | 7 ms | 9296 KB | Output is correct |
3 | Correct | 7 ms | 9296 KB | Output is correct |
4 | Correct | 10 ms | 9296 KB | Output is correct |
5 | Correct | 9 ms | 9296 KB | Output is correct |
6 | Correct | 8 ms | 9296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 407 ms | 9080 KB | Output is correct |
2 | Correct | 380 ms | 9204 KB | Output is correct |
3 | Correct | 387 ms | 9296 KB | Output is correct |
4 | Correct | 397 ms | 9296 KB | Output is correct |
5 | Correct | 421 ms | 9296 KB | Output is correct |
6 | Correct | 552 ms | 9296 KB | Output is correct |
7 | Correct | 9 ms | 9296 KB | Output is correct |
8 | Correct | 7 ms | 9296 KB | Output is correct |
9 | Correct | 7 ms | 9296 KB | Output is correct |
10 | Correct | 10 ms | 9296 KB | Output is correct |
11 | Correct | 9 ms | 9296 KB | Output is correct |
12 | Correct | 8 ms | 9296 KB | Output is correct |
13 | Runtime error | 3 ms | 9296 KB | Execution killed with signal 8 (could be triggered by violating memory limits) |
14 | Halted | 0 ms | 0 KB | - |