Submission #2162315
Source Code Expand
import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int N = scan.nextInt(); long A = scan.nextLong(); long B = scan.nextLong(); long[] 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){ int index=Math.max(lindex,0); while(S[i]-S[index]>=B)++index; long dp = (index==0 ? 0: (sum[index-1] - (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){ int index=Math.max(lindex,0); while(S[i]-S[index]>=B)++index; long dp = (index==0 ? 0: (sum[index-1]-(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]-sum[lindex]+mod)%mod)); } }
Submission Info
Submission Time | |
---|---|
Task | C - Division into Two |
User | inmir |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1501 Byte |
Status | RE |
Exec Time | 2109 ms |
Memory | 64656 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 | 539 ms | 46500 KB |
02.txt | AC | 516 ms | 49912 KB |
03.txt | AC | 517 ms | 50744 KB |
04.txt | AC | 484 ms | 47164 KB |
05.txt | TLE | 2109 ms | 61044 KB |
06.txt | AC | 505 ms | 51712 KB |
07.txt | AC | 439 ms | 48828 KB |
08.txt | AC | 512 ms | 53324 KB |
09.txt | AC | 442 ms | 50532 KB |
10.txt | AC | 497 ms | 51676 KB |
11.txt | AC | 431 ms | 48384 KB |
12.txt | RE | 481 ms | 51336 KB |
13.txt | AC | 522 ms | 48860 KB |
14.txt | AC | 438 ms | 47864 KB |
15.txt | AC | 495 ms | 64656 KB |
16.txt | RE | 416 ms | 50868 KB |
17.txt | RE | 478 ms | 47612 KB |
18.txt | RE | 496 ms | 51184 KB |
19.txt | WA | 493 ms | 47844 KB |
20.txt | AC | 476 ms | 48776 KB |
21.txt | AC | 464 ms | 49760 KB |
22.txt | WA | 782 ms | 49292 KB |
23.txt | WA | 445 ms | 48348 KB |
24.txt | WA | 428 ms | 47968 KB |
25.txt | AC | 509 ms | 49248 KB |
26.txt | AC | 523 ms | 48908 KB |
27.txt | AC | 521 ms | 51280 KB |
28.txt | AC | 493 ms | 47648 KB |
29.txt | WA | 480 ms | 57776 KB |
30.txt | WA | 503 ms | 59292 KB |
31.txt | WA | 475 ms | 48360 KB |
32.txt | WA | 484 ms | 50036 KB |
33.txt | WA | 509 ms | 52448 KB |
34.txt | WA | 509 ms | 47128 KB |
35.txt | WA | 628 ms | 50228 KB |
36.txt | RE | 423 ms | 49956 KB |
37.txt | TLE | 2109 ms | 48704 KB |
38.txt | TLE | 2109 ms | 50884 KB |
39.txt | TLE | 2109 ms | 51156 KB |
40.txt | AC | 413 ms | 46316 KB |
41.txt | AC | 439 ms | 49480 KB |
42.txt | AC | 430 ms | 48016 KB |
43.txt | RE | 491 ms | 48120 KB |
44.txt | RE | 454 ms | 64548 KB |
45.txt | RE | 489 ms | 51128 KB |
46.txt | RE | 443 ms | 50648 KB |
47.txt | AC | 464 ms | 51036 KB |
48.txt | AC | 434 ms | 47044 KB |
49.txt | RE | 93 ms | 21204 KB |
50.txt | AC | 93 ms | 21460 KB |
51.txt | AC | 93 ms | 17492 KB |
52.txt | AC | 92 ms | 21716 KB |
53.txt | RE | 94 ms | 20692 KB |
54.txt | AC | 95 ms | 21716 KB |
55.txt | AC | 92 ms | 21716 KB |
56.txt | AC | 92 ms | 19796 KB |
57.txt | AC | 92 ms | 21972 KB |
58.txt | AC | 93 ms | 18900 KB |
59.txt | AC | 91 ms | 18516 KB |
60.txt | AC | 92 ms | 19028 KB |
61.txt | AC | 92 ms | 18640 KB |
62.txt | AC | 91 ms | 18772 KB |
63.txt | AC | 91 ms | 23892 KB |
64.txt | AC | 92 ms | 19796 KB |
s1.txt | AC | 93 ms | 20564 KB |
s2.txt | AC | 93 ms | 17492 KB |
s3.txt | AC | 92 ms | 21844 KB |
s4.txt | AC | 92 ms | 19796 KB |