Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- set<ll>c;
- void fac(int n, set<ll>s) {
- for (int i=2; i<=n; i++) {
- if (n%i==0) {
- c.insert(i);
- s.insert(i);
- while (n>0 && n%i==0) {
- n/=i;
- }
- }
- }
- if (s.empty()) c.insert(n);
- }
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- ll t;
- cin >> t;
- while (t--) {
- ll n;
- cin >> n;
- ll mx=LONG_LONG_MIN;
- ll mn=LONG_LONG_MAX;
- ll rs=0;
- ll sum=0;
- while (n--) {
- int x;
- cin >> x;
- if (x==0) {
- mx=max(sum,mx);
- mn=min(sum,mn);
- if (sum)rs++;
- sum=0;
- }
- else sum+=x;
- }
- mx=max(sum,mx);
- if (sum) mn=min(sum,mn);
- cout << mx << " " << mn << " " << rs << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment