Submission #2162321
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]-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 | 1593 Byte |
Status | RE |
Exec Time | 549 ms |
Memory | 63160 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 | 455 ms | 47244 KB |
02.txt | AC | 529 ms | 49068 KB |
03.txt | AC | 505 ms | 50820 KB |
04.txt | AC | 495 ms | 51932 KB |
05.txt | RE | 543 ms | 51172 KB |
06.txt | AC | 458 ms | 50468 KB |
07.txt | AC | 511 ms | 48208 KB |
08.txt | AC | 496 ms | 46184 KB |
09.txt | AC | 532 ms | 49352 KB |
10.txt | AC | 455 ms | 47672 KB |
11.txt | AC | 549 ms | 53668 KB |
12.txt | RE | 480 ms | 49508 KB |
13.txt | AC | 465 ms | 49892 KB |
14.txt | AC | 498 ms | 50992 KB |
15.txt | AC | 465 ms | 63160 KB |
16.txt | RE | 418 ms | 50452 KB |
17.txt | RE | 489 ms | 49208 KB |
18.txt | RE | 485 ms | 50108 KB |
19.txt | WA | 475 ms | 49188 KB |
20.txt | AC | 467 ms | 48224 KB |
21.txt | AC | 470 ms | 49816 KB |
22.txt | WA | 500 ms | 50752 KB |
23.txt | WA | 435 ms | 49912 KB |
24.txt | WA | 480 ms | 48744 KB |
25.txt | AC | 525 ms | 48048 KB |
26.txt | AC | 477 ms | 49524 KB |
27.txt | AC | 499 ms | 59516 KB |
28.txt | AC | 522 ms | 48304 KB |
29.txt | WA | 494 ms | 59656 KB |
30.txt | WA | 503 ms | 59092 KB |
31.txt | WA | 525 ms | 49684 KB |
32.txt | WA | 549 ms | 46920 KB |
33.txt | WA | 517 ms | 49344 KB |
34.txt | WA | 483 ms | 48056 KB |
35.txt | WA | 498 ms | 52636 KB |
36.txt | RE | 422 ms | 50388 KB |
37.txt | RE | 473 ms | 50312 KB |
38.txt | RE | 435 ms | 50548 KB |
39.txt | RE | 479 ms | 46832 KB |
40.txt | AC | 451 ms | 51140 KB |
41.txt | AC | 439 ms | 50784 KB |
42.txt | AC | 392 ms | 47424 KB |
43.txt | RE | 490 ms | 50612 KB |
44.txt | RE | 486 ms | 49680 KB |
45.txt | RE | 476 ms | 51092 KB |
46.txt | RE | 435 ms | 50144 KB |
47.txt | AC | 492 ms | 49324 KB |
48.txt | AC | 430 ms | 48920 KB |
49.txt | RE | 92 ms | 19796 KB |
50.txt | AC | 93 ms | 21716 KB |
51.txt | AC | 92 ms | 21972 KB |
52.txt | AC | 92 ms | 21844 KB |
53.txt | RE | 92 ms | 21716 KB |
54.txt | AC | 93 ms | 20688 KB |
55.txt | AC | 91 ms | 18900 KB |
56.txt | AC | 92 ms | 19024 KB |
57.txt | AC | 94 ms | 18900 KB |
58.txt | AC | 93 ms | 21716 KB |
59.txt | AC | 92 ms | 19924 KB |
60.txt | AC | 92 ms | 19028 KB |
61.txt | AC | 93 ms | 21332 KB |
62.txt | AC | 95 ms | 19540 KB |
63.txt | AC | 91 ms | 19924 KB |
64.txt | AC | 93 ms | 20688 KB |
s1.txt | AC | 92 ms | 20692 KB |
s2.txt | AC | 93 ms | 21844 KB |
s3.txt | AC | 94 ms | 19668 KB |
s4.txt | AC | 92 ms | 19284 KB |