Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- using namespace std;
- using ll = long long;
- using ld = long double;
- void cv(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- ll t,n;
- vector <ll> a;
- vector <ll> pref, max_pref, res,ans;//max_pref - храним индексы максимального префикса
- ll wrk(){cout<<"\n";
- pref.resize(n);
- max_pref.resize(n);
- res.resize(n);
- ans.resize(n);
- pref[0] = a[0];
- max_pref[0] = max(0, a[0]);
- for (int i = 1; i < n; ++ i){
- pref[i] = pref[i-1] + a[i];
- max_pref[i] = max(pref[i], max_pref[i-1]);
- res[i] =
- }
- cout<<"a\n";cv(a);
- cout<<"pref\n";cv(pref);
- cout<<"max_pref\n"; cv(max_pref);
- cout<<"res\n"; cv(res);
- cout<<"ans\n";cv(ans);
- return ans[n-1];
- }
- void go(){
- cin>>n;
- a.resize(n); for (ll &x: a) cin>>x;
- ll r = wrk();
- cout<<r<<'\n';
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin>>t;
- for (int i = 0; i < t;++i){
- go();
- }
- }
Add Comment
Please, Sign In to add comment