fork download
  1. #include<iostream>
  2. #include<math.h>
  3. #include<iomanip>
  4. #include <string>
  5. #include<algorithm>
  6. #include <vector>
  7. #include<set>
  8. #include<queue>
  9. #include<deque>
  10. #include<stack>
  11. #include<map>
  12. #define all(v) v.begin(), v.end()
  13. #define Lamine_YAMAL ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  14. typedef long long ll;
  15. typedef double ld;
  16. using namespace std;
  17. int gcd(int a, int b) {
  18. while (b != 0) {
  19. int x = a;
  20. a = b;
  21. b = x % b;
  22. }
  23. return a;
  24. }
  25. int lcm(int a, int b) {
  26. return (a * b) / gcd(a, b);
  27. }
  28. long long rev_num(long long n) {
  29. long long rev = 0;
  30. while (n > 0)
  31. {
  32. int digit = n % 10;
  33. rev = rev * 10 + digit;
  34. n /= 10;
  35. }
  36. return rev;
  37. }
  38. bool isPrime(long long n) {
  39. if (n <= 1) return false;
  40. for (int i = 2; i * i <= n; i++)
  41. if (n % i == 0) return false;
  42. return true;
  43. }
  44. bool palindrome_string(string s)
  45. {
  46. string t = s;
  47. reverse(t.begin(), t.end());
  48. return s == t;
  49. }
  50. bool islucky(long long n) {
  51. while (n > 0) {
  52. int digit = n % 10;
  53. if (digit != 4 && digit != 7) {
  54. return false;
  55. }
  56. n /= 10;
  57. }
  58. return true;
  59. }
  60. bool preceed(ll x, ll y) {
  61. return x > y;
  62. }
  63. bool compare(pair<string, ll> a, pair<string, ll> b) {
  64. if (a.second != b.second)
  65. return a.second > b.second;
  66. return a.first < b.first;
  67. }
  68. //priority_queue<int, vector<int>, greater<int>> ans;
  69.  
  70. int main() {
  71.  
  72. Lamine_YAMAL
  73. //freopen("mex.in", "r", stdin);
  74. int t; cin >> t;
  75. while (t--) {
  76. int n, s; cin >> n >> s; vector<int>v(n);
  77. for (int i = 0;i < n;i++)
  78. cin >> v[i];
  79.  
  80. ll sum = s; pair<int, int>ans;
  81. int l = 0; int r = l;
  82. int len = 0;
  83. while (r < n) {
  84.  
  85. sum += v[r];
  86.  
  87. while (sum < 0) {
  88. sum -= v[l];
  89. l++;
  90. }
  91.  
  92. len = max(len, r - l + 1);
  93.  
  94. if (len) {
  95. ans.first = l;
  96. ans.second = r;
  97. }
  98.  
  99. r++;
  100. }
  101.  
  102. if (len)
  103. cout << ans.first+1 << " "
  104. << ans.second+1 << endl;
  105. else
  106. cout << -1<<endl;
  107.  
  108.  
  109. }
  110.  
  111.  
  112. return 0;
  113. }
  114.  
  115.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty