report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Subarray - FlandreOJ: Flandre Online Judge

Subarray

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $a$ consisting of $n$ integers and an integer $S$, find the longest contiguous subarray in $a$ whose sum does not exceed $S$. ### Input - The first line contains two integers $n, S$. - The second line contains $n$ integers $a_i$. ### Output - Print a single integer representing the length of the longest contiguous subarray that satisfies the condition. If there is no satisfied subarray, print `-1`. ### Constraints - $1 \leq n \leq 2 \times 10^5$. - $0 \leq |a_i|, |S| \leq 10^9$. ### Example Input: ``` 3 -1 4 -3 2 ``` Output ``` 2 ```
Introduction to Binary Search
Binary search
Binary search 2
Binary search 3
Large subarray
Count query
Counting pairs
The k-th candy
Triangle edges
Hamming number
Consecutive integers
Gnimmah distance
Subarray
Topic
Prefix sum
Binary search
Rating 1400
Solution (1) Solution