Submission #1074500
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; const int mod = 1e9 + 7; int n; lint p, q, a[100005]; lint d12[100005], d21[100005]; int lo1[100005], lo2[100005]; struct seg{ lint tree[100010]; void add(int x, lint v){ while(x <= n+5){ tree[x] += v; tree[x] %= mod; x += x & -x; } } lint query(int x){ lint ret = 0; while(x){ ret += tree[x]; ret %= mod; x -= x & -x; } return ret; } lint query(int s, int e){ if(s > e) return 0; return (query(e) - query(s-1) + mod) % mod; } }bit1, bit2; int main(){ cin >> n >> p >> q; for(int i=1; i<=n; i++){ scanf("%lld",&a[i]); } int l1 = n, l2 = n; if(p > q) swap(p, q); for(int i=n; i; i--){ if(a[i+1] - a[i] < p) l1 = i; if(a[i+1] - a[i] < q) l2 = i; lo1[i] = l1; lo2[i] = l2; } lint ret = 0; for(int i=n; i>1; i--){ if(lo1[i] == n) d21[i] = 1; if(lo2[i] == n) d12[i] = 1; int lb1 = lower_bound(a+1, a+n+1, a[i-1] + p) - a; int lb2 = lower_bound(a+1, a+n+1, a[i-1] + q) - a; lb1 = max(lb1, i+1); lb2 = max(lb2, i+1); d12[i] += bit2.query(lb1, lo2[i] + 1); d21[i] += bit1.query(lb2, lo1[i] + 1); d12[i] %= mod; d21[i] %= mod; bit1.add(i, d12[i]); bit2.add(i, d21[i]); if(lo1[1] >= i-1) ret += d12[i]; if(lo2[1] >= i-1) ret += d21[i]; } cout << ret % mod << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | koosaga |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1440 Byte |
Status | WA |
Exec Time | 52 ms |
Memory | 4992 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&a[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 52 ms | 4992 KB |
02.txt | AC | 51 ms | 4864 KB |
03.txt | AC | 52 ms | 4864 KB |
04.txt | AC | 52 ms | 4992 KB |
05.txt | WA | 50 ms | 4992 KB |
06.txt | AC | 52 ms | 4864 KB |
07.txt | AC | 52 ms | 4864 KB |
08.txt | AC | 52 ms | 4864 KB |
09.txt | AC | 52 ms | 4992 KB |
10.txt | AC | 52 ms | 4992 KB |
11.txt | AC | 52 ms | 4864 KB |
12.txt | WA | 50 ms | 4992 KB |
13.txt | AC | 52 ms | 4864 KB |
14.txt | AC | 52 ms | 4992 KB |
15.txt | AC | 52 ms | 4864 KB |
16.txt | WA | 43 ms | 4992 KB |
17.txt | WA | 45 ms | 4864 KB |
18.txt | WA | 47 ms | 4864 KB |
19.txt | AC | 44 ms | 4864 KB |
20.txt | AC | 46 ms | 4864 KB |
21.txt | AC | 47 ms | 4992 KB |
22.txt | AC | 46 ms | 4992 KB |
23.txt | AC | 43 ms | 4864 KB |
24.txt | AC | 45 ms | 4992 KB |
25.txt | AC | 50 ms | 4992 KB |
26.txt | AC | 49 ms | 4864 KB |
27.txt | AC | 49 ms | 4992 KB |
28.txt | AC | 48 ms | 4992 KB |
29.txt | AC | 46 ms | 4992 KB |
30.txt | AC | 47 ms | 4864 KB |
31.txt | AC | 45 ms | 4864 KB |
32.txt | AC | 46 ms | 4992 KB |
33.txt | AC | 47 ms | 4864 KB |
34.txt | AC | 44 ms | 4864 KB |
35.txt | AC | 47 ms | 4992 KB |
36.txt | WA | 43 ms | 4864 KB |
37.txt | WA | 44 ms | 4864 KB |
38.txt | WA | 45 ms | 4864 KB |
39.txt | WA | 52 ms | 4992 KB |
40.txt | AC | 45 ms | 4992 KB |
41.txt | AC | 43 ms | 4864 KB |
42.txt | AC | 31 ms | 4992 KB |
43.txt | WA | 50 ms | 4992 KB |
44.txt | WA | 52 ms | 4864 KB |
45.txt | WA | 51 ms | 4864 KB |
46.txt | WA | 51 ms | 4864 KB |
47.txt | AC | 52 ms | 4992 KB |
48.txt | AC | 52 ms | 4864 KB |
49.txt | WA | 3 ms | 256 KB |
50.txt | AC | 3 ms | 256 KB |
51.txt | AC | 3 ms | 256 KB |
52.txt | AC | 3 ms | 256 KB |
53.txt | WA | 3 ms | 256 KB |
54.txt | AC | 3 ms | 256 KB |
55.txt | AC | 3 ms | 256 KB |
56.txt | AC | 3 ms | 256 KB |
57.txt | AC | 3 ms | 256 KB |
58.txt | AC | 3 ms | 256 KB |
59.txt | AC | 3 ms | 256 KB |
60.txt | AC | 3 ms | 256 KB |
61.txt | AC | 3 ms | 256 KB |
62.txt | AC | 3 ms | 256 KB |
63.txt | AC | 3 ms | 256 KB |
64.txt | AC | 3 ms | 256 KB |
s1.txt | AC | 3 ms | 256 KB |
s2.txt | AC | 3 ms | 256 KB |
s3.txt | AC | 3 ms | 256 KB |
s4.txt | AC | 3 ms | 256 KB |