fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define name "test"
  4. #define ll long long
  5.  
  6. ll a[100005];
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0);
  10. cout.tie(0);cin.tie(0);
  11. int n, S; cin >> n >> S;
  12. for(int i = 1; i <= n; i++){
  13. cin >> a[i];
  14. }
  15. int dodai = 1e9, kq1 = 0, kq2 = 0;
  16.  
  17. for(int l = 1; l <= n; l++){
  18. ll sum = 0;
  19. for(int r = l; r <= n; r++){
  20. // doan con [l, r]
  21. sum = sum + a[r];
  22. // sum tu [l, r]
  23.  
  24. if(sum >= S){
  25. if(dodai > r - l + 1){
  26. dodai = r - l + 1;
  27. kq1 = l;
  28. kq2 = r;
  29. }
  30. }
  31. }
  32. }
  33.  
  34.  
  35. cout << dodai << endl;
  36. for(int i = kq1; i <= kq2; i++){
  37. cout << a[i] << " ";
  38. }
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
1
0