Submission #1774991
Source Code Expand
#include <bits/stdc++.h> #define lsb(x) ((x) & -(x)) #define MOD 1000000007 using namespace std; const long long NMAX = 100010; inline void add(long long & a, long long b) { a += b; if (a >= MOD) a -= MOD; } class Aib { vector <long long> pozitii; vector <long long> aib; public: Aib() { aib = vector <long long> (NMAX + 5); } void update(long long val, long long poz) { poz++; while (poz <= NMAX) { if (aib[poz] == 0) pozitii.push_back(poz); add(aib[poz], val); poz += lsb(poz); } } long long query(long long poz) { poz++; long long ans(0); while (poz) { add(ans, aib[poz]); poz -= lsb(poz); } return ans; } void clear() { for (auto i : pozitii) aib[i] = 0; pozitii.clear(); } }; Aib aib[2]; long long s[100010]; long long dif[2]; long long pozmax(long long x, long long dif) { /// poztia maxima a.i. s[x] - s[max] >= dif long long p(0), q(1 << 20); while (q >>= 1) if (p + q < x && s[x] - s[p + q] >= dif) p += q; return p; } void tranz(long long x) { long long updates[2]; for (long long i(0); i <= 1; i++) { updates[1 - i] = aib[i].query(pozmax(x + 1, dif[1 - i])); if (s[x + 1] - s[x] < dif[i]) aib[i].clear(); } for (long long i(0); i <= 1; i++) aib[i].update(updates[i], x); } //long long dp[2][10][10]; int main() { long long n; cin >> n >> dif[0] >> dif[1]; for (long long i(1); i <= n; i++) cin >> s[i]; aib[0].update(1, 0); aib[1].update(1, 0); /*for (long long q(0); q <= 1; q++) { for (long long j(0); j <= n; j++) { dp[q][1][j] = aib[q].query(j) - aib[q].query(j - 1); } }*/ for (long long i(1); i < n; i++) { tranz(i); /*for (long long q(0); q <= 1; q++) { for (long long j(0); j <= n; j++) { dp[q][i + 1][j] = aib[q].query(j) - aib[q].query(j - 1); } } } for (long long q(0); q <= 1; q++) { for (long long i(1); i <= n; i++) { for (long long j(0); j <= n; j++) { cout << dp[q][i][j] << " \n"[j == n]; } } cout << '\n';*/ } cout << (aib[0].query(n) + aib[1].query(n)) % MOD; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | teomrn |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 2578 Byte |
Status | AC |
Exec Time | 99 ms |
Memory | 7408 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 1100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 90 ms | 2556 KB |
02.txt | AC | 85 ms | 2560 KB |
03.txt | AC | 88 ms | 2560 KB |
04.txt | AC | 86 ms | 2560 KB |
05.txt | AC | 86 ms | 3704 KB |
06.txt | AC | 86 ms | 2560 KB |
07.txt | AC | 89 ms | 2560 KB |
08.txt | AC | 89 ms | 2560 KB |
09.txt | AC | 89 ms | 2560 KB |
10.txt | AC | 89 ms | 2560 KB |
11.txt | AC | 88 ms | 2560 KB |
12.txt | AC | 99 ms | 4296 KB |
13.txt | AC | 89 ms | 2560 KB |
14.txt | AC | 87 ms | 2560 KB |
15.txt | AC | 86 ms | 2560 KB |
16.txt | AC | 53 ms | 3704 KB |
17.txt | AC | 61 ms | 3704 KB |
18.txt | AC | 73 ms | 3704 KB |
19.txt | AC | 63 ms | 2688 KB |
20.txt | AC | 64 ms | 2560 KB |
21.txt | AC | 64 ms | 2560 KB |
22.txt | AC | 70 ms | 7408 KB |
23.txt | AC | 54 ms | 2560 KB |
24.txt | AC | 60 ms | 2560 KB |
25.txt | AC | 79 ms | 2560 KB |
26.txt | AC | 76 ms | 2560 KB |
27.txt | AC | 75 ms | 2560 KB |
28.txt | AC | 76 ms | 2560 KB |
29.txt | AC | 70 ms | 2560 KB |
30.txt | AC | 70 ms | 2560 KB |
31.txt | AC | 68 ms | 2560 KB |
32.txt | AC | 72 ms | 2560 KB |
33.txt | AC | 78 ms | 2560 KB |
34.txt | AC | 62 ms | 2688 KB |
35.txt | AC | 83 ms | 3196 KB |
36.txt | AC | 56 ms | 4296 KB |
37.txt | AC | 55 ms | 3704 KB |
38.txt | AC | 56 ms | 3704 KB |
39.txt | AC | 92 ms | 3704 KB |
40.txt | AC | 51 ms | 2560 KB |
41.txt | AC | 57 ms | 2560 KB |
42.txt | AC | 49 ms | 2560 KB |
43.txt | AC | 94 ms | 4296 KB |
44.txt | AC | 94 ms | 4296 KB |
45.txt | AC | 93 ms | 4292 KB |
46.txt | AC | 93 ms | 4292 KB |
47.txt | AC | 90 ms | 2944 KB |
48.txt | AC | 94 ms | 2688 KB |
49.txt | AC | 2 ms | 1792 KB |
50.txt | AC | 2 ms | 1792 KB |
51.txt | AC | 2 ms | 1792 KB |
52.txt | AC | 2 ms | 1792 KB |
53.txt | AC | 2 ms | 1792 KB |
54.txt | AC | 2 ms | 1792 KB |
55.txt | AC | 2 ms | 1792 KB |
56.txt | AC | 2 ms | 1792 KB |
57.txt | AC | 2 ms | 1792 KB |
58.txt | AC | 2 ms | 1792 KB |
59.txt | AC | 2 ms | 1792 KB |
60.txt | AC | 2 ms | 1792 KB |
61.txt | AC | 2 ms | 1792 KB |
62.txt | AC | 2 ms | 1792 KB |
63.txt | AC | 2 ms | 1792 KB |
64.txt | AC | 2 ms | 1792 KB |
s1.txt | AC | 2 ms | 1792 KB |
s2.txt | AC | 2 ms | 1792 KB |
s3.txt | AC | 2 ms | 1792 KB |
s4.txt | AC | 2 ms | 1792 KB |