Time Lapse :NONE 1806.c123456789101112131415161718192021#include <stdio.h>#define gc() getchar_unlocked()long psum[100001];int fRI(){ int N=gc(),ret = 0; for(;N<48||N>57;N=gc()); do{ ret = (ret<<3) + (ret<<1) + (N&0b1111); N = gc(); }while(0x30<=N); return ret;}int main() { register int N = fRI(), target = fRI(), ans = 100002, i, j; for (i = 1; i <= N; ++i) psum[i] = fRI() + psum[i - 1]; for (i = 0; i < N; ++i) for (j = i + 1; j <= N && j < i + ans; ++j) if (psum[j] >= target + psum[i]) { ans = j - i; break; } printf("%d", ans==100002 ? 0 : ans);} 123456789101112131415161718192021222324252627282930313233#include <iostream>#include <list>#include <map>#include <unordered_map>#include <vector>using namespace std;vector<int> arr(100000);int N, S;int solution() { if(arr[0] >= S) return 1; int from = 0, tail = 0, sum = arr[0], res = N + 1; while(tail < N) { if(sum >= S) { sum -= arr[from++]; if(from > tail) return 1; } else { sum += arr[++tail]; } if(sum >= S) res = min(res, tail - from + 1); } return res == N + 1 ? 0 : res;}int main() { scanf("%d %d",&N, &S); for(int i = 0; i < N; i++) scanf("%d", &arr[i]); cout<<solution();}