Submission #1691773
Source Code Expand
// Copyright (C) 2017 __debug. // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; version 3 // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; If not, see <http://www.gnu.org/licenses/>. #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #define x first #define y second #define MP std::make_pair #define SZ(x) ((int)(x).size()) #define ALL(x) (x).begin(), (x).end() #define DEBUG(...) fprintf(stderr, __VA_ARGS__) #ifdef __linux__ #define getchar getchar_unlocked #define putchar putchar_unlocked #endif using std::pair; using std::vector; using std::string; typedef long long LL; typedef pair<int, int> Pii; const int oo = 0x3f3f3f3f; template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; } template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; } string procStatus() { std::ifstream t("/proc/self/status"); return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>()); } template<typename T> T read(T &x) { int f = 1; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f = (ch == '-' ? -1 : 1); for (x = 0; isdigit(ch); ch = getchar()) x = 10 * x + ch - '0'; return x *= f; } template<typename T> void write(T x) { if (x == 0) { putchar('0'); return; } if (x < 0) { putchar('-'); x = -x; } static char s[20]; int top = 0; for (; x; x /= 10) s[++top] = x % 10 + '0'; while (top) putchar(s[top--]); } // EOT const int MAXN = 1e5 + 5; const int MOD = 1e9 + 7; int N; LL A, B; LL S[MAXN]; void input() { read(N); read(A); read(B); for (int i = 1; i <= N; ++i) { read(S[i]); } } void solve() { static int dpA[MAXN], dpB[MAXN]; int pA = 0, pB = 0; int sA = 1, sB = 1; dpA[0] = dpB[0] = 1; for (int i = 2; i <= N; ++i) { while (pA + 1 < i - 1 && S[i] - S[pA + 1] >= A) (sA += dpB[++pA]) %= MOD; while (pB + 1 < i - 1 && S[i] - S[pB + 1] >= B) (sB += dpA[++pB]) %= MOD; dpA[i - 1] = sA; dpB[i - 1] = sB; if (S[i] - S[i - 1] < A) { sB = 0; pB = i - 2; } if (S[i] - S[i - 1] < B) { sA = 0; pA = i - 2; } } while (pA + 1 < N) (sA += dpB[++pA]) %= MOD; while (pB + 1 < N) (sB += dpA[++pB]) %= MOD; int ans = (sA + sB) % MOD; printf("%d\n", ans); } int main() { #ifdef __DEBUG freopen("C.in", "r", stdin); freopen("C.out", "w", stdout); #endif input(); solve(); return 0; } // 曾子杀彘 / 曾子烹彘 // [先秦] 韩非 // 曾子之妻之市,其子随之而泣。 // 其母曰:“女还,顾反为女杀彘。” // 妻子适市来,曾子欲捕彘杀之。 // 妻止之曰:“特与婴儿戏耳。” // 曾子曰:“婴儿非与戏也。婴儿非有智也,待父母而学者也, // 听父母之教。今子欺之,是教子欺也。 // 母欺子,子而不信其母,非所以成教也。” // 遂烹彘也。(女 通:汝)
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | Ivlleiooq |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 3727 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 1920 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 | 8 ms | 1792 KB |
02.txt | AC | 7 ms | 1792 KB |
03.txt | AC | 8 ms | 1792 KB |
04.txt | AC | 7 ms | 1792 KB |
05.txt | AC | 7 ms | 1792 KB |
06.txt | AC | 7 ms | 1792 KB |
07.txt | AC | 8 ms | 1792 KB |
08.txt | AC | 8 ms | 1792 KB |
09.txt | AC | 8 ms | 1792 KB |
10.txt | AC | 8 ms | 1792 KB |
11.txt | AC | 8 ms | 1792 KB |
12.txt | AC | 8 ms | 1792 KB |
13.txt | AC | 8 ms | 1792 KB |
14.txt | AC | 8 ms | 1792 KB |
15.txt | AC | 7 ms | 1792 KB |
16.txt | AC | 5 ms | 1792 KB |
17.txt | AC | 6 ms | 1792 KB |
18.txt | AC | 6 ms | 1792 KB |
19.txt | AC | 5 ms | 1792 KB |
20.txt | AC | 6 ms | 1792 KB |
21.txt | AC | 6 ms | 1792 KB |
22.txt | AC | 6 ms | 1792 KB |
23.txt | AC | 4 ms | 1792 KB |
24.txt | AC | 5 ms | 1792 KB |
25.txt | AC | 7 ms | 1792 KB |
26.txt | AC | 6 ms | 1792 KB |
27.txt | AC | 6 ms | 1792 KB |
28.txt | AC | 7 ms | 1792 KB |
29.txt | AC | 6 ms | 1792 KB |
30.txt | AC | 6 ms | 1792 KB |
31.txt | AC | 6 ms | 1792 KB |
32.txt | AC | 6 ms | 1792 KB |
33.txt | AC | 7 ms | 1792 KB |
34.txt | AC | 5 ms | 1792 KB |
35.txt | AC | 7 ms | 1792 KB |
36.txt | AC | 4 ms | 1792 KB |
37.txt | AC | 4 ms | 1792 KB |
38.txt | AC | 5 ms | 1920 KB |
39.txt | AC | 8 ms | 1792 KB |
40.txt | AC | 4 ms | 1792 KB |
41.txt | AC | 5 ms | 1792 KB |
42.txt | AC | 4 ms | 1792 KB |
43.txt | AC | 8 ms | 1792 KB |
44.txt | AC | 8 ms | 1792 KB |
45.txt | AC | 8 ms | 1792 KB |
46.txt | AC | 8 ms | 1792 KB |
47.txt | AC | 8 ms | 1792 KB |
48.txt | AC | 8 ms | 1792 KB |
49.txt | AC | 1 ms | 256 KB |
50.txt | AC | 1 ms | 256 KB |
51.txt | AC | 1 ms | 256 KB |
52.txt | AC | 1 ms | 256 KB |
53.txt | AC | 1 ms | 256 KB |
54.txt | AC | 1 ms | 256 KB |
55.txt | AC | 1 ms | 256 KB |
56.txt | AC | 1 ms | 256 KB |
57.txt | AC | 1 ms | 256 KB |
58.txt | AC | 1 ms | 256 KB |
59.txt | AC | 1 ms | 256 KB |
60.txt | AC | 1 ms | 256 KB |
61.txt | AC | 1 ms | 256 KB |
62.txt | AC | 1 ms | 256 KB |
63.txt | AC | 1 ms | 256 KB |
64.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |
s4.txt | AC | 1 ms | 256 KB |