제출 #1160275

#제출 시각아이디문제언어결과실행 시간메모리
1160275nurali16Bigger segments (IZhO19_segments)C++20
0 / 100
0 ms328 KiB
//order_of_key (k) : Number of items strictly smaller than k . //find_by_order(k) : K-th element in a set (counting from zero). #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define int long long #define pii pair<int,int> #define F first #define S second #define pb push_back #define len(x) (int)x.size() #define pf push_front #define popb pop_back #define popf pop_front #define all(x) (x).begin(), (x).end() #pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") using namespace std; using namespace __gnu_pbds; const int N = 1e6 + 5; const int mod = 1e9 + 7; const int inf = 1e18; int a[N]; signed main(/*Nurali*/){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 1;i<=n;i++){ cin >> a[i]; } int sum = 0 , pr = 0 , k = 0 ,cnt = 0,mx = 1; for(int i = 1;i<=n;i++){ pr+=a[i]; sum = pr; k = 0; cnt = 1; for(int j = i+1;j<=n;j++){ k+=a[j]; if(sum<=k){ cnt++; sum = k; k = 0; } } if(k!=0) cnt++; mx = max(cnt,mx); } // for(int i = n;i>=1;i--){ // pr+=a[i]; // sum = pr; // k = 0; // cnt = 1; // for(int j = i-1;j>=1;j--){ // k+=a[i]; // if(sum<k){ // k-=a[i]; // cnt++; // sum = k; // } // } // // mx = max(mx,) // } cout << mx; return 0; } /* //order_of_key(k): Number of items strictly smaller than k . //find_by_order(k): K-th element in a set (counting from zero). //sum of squares n*(n+1)*(2n+1)/6 //sum of cubes [n*(n+1)/2]^2 //sum of squares for odds n*(4*n*n-1)/3 //sum of cubes for odds n*n*(2*n*n-1) //a/b%mod = a*(b^(m-2)%mod) //(a>>x)&1 == 0 //a^b = (a+b)-2(a&b) //srand(time(0))-always changing bool cmp(pii a,pii b){ if (a.F == b.F){ return a.S < b.S; } // if (a.F > b.F) return 1; // else return 0; return a.F > b.F; } sisteme 101010 for(char c : s) x = x*k + (c-48); */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...