lina_os

Untitled

Apr 2nd, 2025 (edited)
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. set<ll>c;
  7.  
  8. void fac(int n, set<ll>s) {
  9. for (int i=2; i<=n; i++) {
  10. if (n%i==0) {
  11. c.insert(i);
  12. s.insert(i);
  13. while (n>0 && n%i==0) {
  14. n/=i;
  15. }
  16. }
  17. }
  18. if (s.empty()) c.insert(n);
  19. }
  20.  
  21. int main() {
  22. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  23. ll t;
  24. cin >> t;
  25. while (t--) {
  26. ll n;
  27. cin >> n;
  28. ll mx=LONG_LONG_MIN;
  29. ll mn=LONG_LONG_MAX;
  30. ll rs=0;
  31. ll sum=0;
  32. while (n--) {
  33. int x;
  34. cin >> x;
  35. if (x==0) {
  36. mx=max(sum,mx);
  37. mn=min(sum,mn);
  38. if (sum)rs++;
  39. sum=0;
  40. }
  41. else sum+=x;
  42. }
  43. mx=max(sum,mx);
  44. if (sum) mn=min(sum,mn);
  45. cout << mx << " " << mn << " " << rs << endl;
  46. }
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment