Submission #2162331
Source Code Expand
import java.util.Scanner; class Main{ static int N; static long A,B; static long[] S; static int findIndex(long s){ int left=0,right=N+1; while(right-left>1){ int center=(left+right)/2; if(s-S[center]>=B)left=center; else right=center; } return left; } public static void main(String[] args){ Scanner scan = new Scanner(System.in); N = scan.nextInt(); A = scan.nextLong(); B = scan.nextLong(); S = new long[N+1]; long[] sum=new long[N+1]; sum[0]=1; S[0] = -B; for(int i=1;i<=N;++i)S[i]=scan.nextLong(); int lindex=-1; long mod = (long)1e9+7; if(A>B){ long a = A; A=B; B=a; } for(int i=2;i<=N;++i)if(S[i]-S[i-2]<A){ System.out.println(0); return; } for(int i=1;i<=N;++i){ if(S[i]-S[i-1]<A){ long dp = (sum[findIndex(S[i])] - (lindex>=0 ? sum[lindex]:0)+mod)%mod; sum[i]=(sum[i-1]+dp)%mod; lindex=i-2; }else if(S[i]-S[i-1]<B){ long dp = (sum[findIndex(S[i])]-(lindex>=0 ? sum[lindex]:0)+mod)%mod; sum[i]=(sum[i-1]+dp)%mod; }else{ long dp = (sum[i-1] - (lindex>=0 ? sum[lindex]:0)+mod)%mod; sum[i]=(sum[i-1]+dp)%mod; } } System.out.println(((sum[N]-(lindex>=0 ? sum[lindex]:0)+mod)%mod)); } }
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | inmir |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1609 Byte |
Status | WA |
Exec Time | 638 ms |
Memory | 59072 KB |
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 | 448 ms | 47428 KB |
02.txt | AC | 510 ms | 49956 KB |
03.txt | AC | 435 ms | 51384 KB |
04.txt | AC | 473 ms | 44572 KB |
05.txt | AC | 476 ms | 46688 KB |
06.txt | AC | 557 ms | 51104 KB |
07.txt | AC | 510 ms | 50048 KB |
08.txt | AC | 510 ms | 53204 KB |
09.txt | AC | 464 ms | 48724 KB |
10.txt | AC | 504 ms | 52532 KB |
11.txt | AC | 451 ms | 50156 KB |
12.txt | AC | 453 ms | 46716 KB |
13.txt | AC | 465 ms | 50396 KB |
14.txt | AC | 453 ms | 49956 KB |
15.txt | AC | 537 ms | 52724 KB |
16.txt | AC | 437 ms | 50788 KB |
17.txt | AC | 486 ms | 47416 KB |
18.txt | AC | 510 ms | 48160 KB |
19.txt | WA | 463 ms | 46816 KB |
20.txt | AC | 472 ms | 49052 KB |
21.txt | AC | 469 ms | 48864 KB |
22.txt | WA | 472 ms | 49852 KB |
23.txt | WA | 427 ms | 45776 KB |
24.txt | WA | 481 ms | 50216 KB |
25.txt | AC | 493 ms | 45404 KB |
26.txt | AC | 515 ms | 49232 KB |
27.txt | AC | 490 ms | 51112 KB |
28.txt | AC | 510 ms | 53336 KB |
29.txt | WA | 466 ms | 46948 KB |
30.txt | WA | 638 ms | 56232 KB |
31.txt | WA | 518 ms | 50440 KB |
32.txt | WA | 500 ms | 46604 KB |
33.txt | WA | 524 ms | 51428 KB |
34.txt | WA | 489 ms | 46948 KB |
35.txt | WA | 526 ms | 51500 KB |
36.txt | AC | 419 ms | 50788 KB |
37.txt | AC | 420 ms | 50484 KB |
38.txt | AC | 439 ms | 57716 KB |
39.txt | AC | 504 ms | 50448 KB |
40.txt | AC | 459 ms | 51048 KB |
41.txt | AC | 464 ms | 47172 KB |
42.txt | AC | 393 ms | 59072 KB |
43.txt | AC | 488 ms | 47844 KB |
44.txt | AC | 444 ms | 49652 KB |
45.txt | AC | 452 ms | 48668 KB |
46.txt | AC | 474 ms | 51220 KB |
47.txt | AC | 423 ms | 51084 KB |
48.txt | AC | 488 ms | 47908 KB |
49.txt | AC | 93 ms | 19668 KB |
50.txt | AC | 94 ms | 21332 KB |
51.txt | AC | 96 ms | 23760 KB |
52.txt | AC | 93 ms | 21716 KB |
53.txt | AC | 94 ms | 19664 KB |
54.txt | AC | 91 ms | 21844 KB |
55.txt | AC | 91 ms | 21844 KB |
56.txt | AC | 92 ms | 19796 KB |
57.txt | AC | 91 ms | 19924 KB |
58.txt | AC | 91 ms | 19924 KB |
59.txt | AC | 92 ms | 23636 KB |
60.txt | AC | 92 ms | 18900 KB |
61.txt | AC | 92 ms | 19924 KB |
62.txt | AC | 92 ms | 18768 KB |
63.txt | AC | 92 ms | 19284 KB |
64.txt | AC | 93 ms | 21716 KB |
s1.txt | AC | 92 ms | 19924 KB |
s2.txt | AC | 95 ms | 23760 KB |
s3.txt | AC | 94 ms | 18900 KB |
s4.txt | AC | 92 ms | 19924 KB |