Submission #887099

#TimeUsernameProblemLanguageResultExecution timeMemory
887099Hovhannes1234Bigger segments (IZhO19_segments)C++17
0 / 100
0 ms604 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3000; int a[N], pref[N]; int main() { int n, sum=0; cin>>n; for(int i=1; i<=n; i++){ cin>>a[i]; sum+=a[i]; } pref[1]=a[1]; for(int i=2; i<=n; i++){ pref[i]=pref[i-1]+a[i]; } int ans=1, s=0, k=0; vector <int> vec; for(int j=1; j<=n; j++){ s=pref[j]; ans=1; k=0; for(int i=j+1; i<=n; i++){ k+=a[i]; if(k >= s){ ans++; s=k; k=0; } } vec.push_back(ans); } sort(vec.begin(), vec.end()); cout<<vec[(int)vec.size()-1]; }
#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...