Submission #48318193


Source Code Expand

Copy
N,X,*A = $<.read.split.map(&:to_i)
S = A.inject([0]){|s,a| s<<s[-1]+a }
D = [nil]*N+[0]
r = N
(N-1).downto(0){|l|
sx = S[l]+X
r -= 1 while sx<S[r]
D[l] = (r-l)+D[r]+(N-r)
}
p D.sum
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
N,X,*A = $<.read.split.map(&:to_i)
S = A.inject([0]){|s,a| s<<s[-1]+a }
D = [nil]*N+[0]
r = N
(N-1).downto(0){|l|
	sx = S[l]+X
	r -= 1 while sx<S[r]
	D[l] = (r-l)+D[r]+(N-r)
}
p D.sum

Submission Info

Submission Time
Task B - Subsegments with Small Sums
User ds14050
Language Ruby (ruby 3.2.2)
Score 500
Code Size 194 Byte
Status AC
Exec Time 119 ms
Memory 42792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 29
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 41 ms 17244 KB
00-sample-002.txt AC 42 ms 17068 KB
00-sample-003.txt AC 41 ms 17056 KB
00-sample-004.txt AC 41 ms 17028 KB
01-001.txt AC 41 ms 17292 KB
01-002.txt AC 42 ms 17548 KB
01-003.txt AC 42 ms 17248 KB
01-004.txt AC 42 ms 17400 KB
01-005.txt AC 41 ms 17552 KB
01-006.txt AC 63 ms 23776 KB
01-007.txt AC 104 ms 38072 KB
01-008.txt AC 85 ms 31668 KB
01-009.txt AC 73 ms 27868 KB
01-010.txt AC 118 ms 42120 KB
01-011.txt AC 119 ms 42004 KB
01-012.txt AC 117 ms 42104 KB
01-013.txt AC 113 ms 42792 KB
01-014.txt AC 115 ms 42096 KB
01-015.txt AC 118 ms 42252 KB
01-016.txt AC 119 ms 42372 KB
01-017.txt AC 116 ms 42072 KB
01-018.txt AC 113 ms 41996 KB
01-019.txt AC 116 ms 42024 KB
01-020.txt AC 119 ms 42100 KB
01-021.txt AC 114 ms 42280 KB
01-022.txt AC 116 ms 42088 KB
01-023.txt AC 117 ms 41944 KB
01-024.txt AC 118 ms 41952 KB
01-025.txt AC 115 ms 41904 KB


2025-04-09 (Wed)
21:27:39 +00:00