Submission #336322

# Submission time Handle Problem Language Result Execution time Memory
336322 2020-12-15T04:40:59 Z amunduzbaev Bigger segments (IZhO19_segments) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long 
#define ld long double 
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 1e6+5;
int n, m, a[N], pref[N], ans;

void perebor(int sum, int last, int gr, int size){
	//cout<<size<<" "<<sum<<" "<<last<<" "<<gr<<"\n";
	if(size == n){
		ans = max(ans, gr);
		return ;
	}
	int i = last+1, cur = a[i];
	i++;
	while(cur < sum && i <= n) cur += a[i], i++;
	//cout<<i<<"\n";
	if(i-1 > n) return;
	sum = cur, size = i-1;
	perebor(sum, i-1, gr+1, size);
	for(; i<=n; i++){
		sum += a[i];
		size++;
		perebor(sum, i, gr+1, size);
	}
}

void solve(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pref[i] = a[i] + pref[i-1];
	}
	perebor(0, 0, 0, 0);
	cout<<ans<<"\n";
	return;
}

signed main(){
	fastios
	int t = 1;
	//cin>>t;
	while(t--) solve();
	return 0;
}
 
 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -