Submission #172700

# Submission time Handle Problem Language Result Execution time Memory
172700 2020-01-02T12:17:20 Z LinusTorvaldsFan Bigger segments (IZhO19_segments) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ind=0;
	int ans=0;
	ll p_sum=0;
	while(ind<n){
		ll sum=0;
		ans++;
		int best_ind=-1;
		int best_pos=n+1;
		ll best_sum=0;
		for(int i=ind;i<n;i++){
			sum+=a[i];
			ll cur=0;
			if(sum<p_sum)continue;
			for(int j=i+1;j<n;j++){
				cur+=a[j];
				if(cur>=sum){
					if(j<=best_pos){
						best_pos=j;
						best_ind=i;
						best_sum=sum;
					}
					break;
				}
			}
		}
		if(best_ind==-1){
			break;
		}
		//cout<<best_ind<<endl;
		ind=best_ind+1;
		p_sum=best_sum;
	}
	cout<<ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -