답안 #173040

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173040 2020-01-03T07:38:51 Z LinusTorvaldsFan Bigger segments (IZhO19_segments) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	vector<ll>pr(n+1);
	for(int i=0;i<n;i++)pr[i+1]=pr[i]+a[i];
	vector<int>ans(n);
	vector<ll> ans_sum(n);
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		ans_sum[i]=sum;
		ans[i]=1;
	}
	for(int i=1;i<n;i++){
		for(int j=i-1;j>=0;j--){
			if(pr[i+1]>=ans_sum[j]+pr[j+1]){
				ans[i]=ans[j]+1;
				ans_sum[i]=pr[i+1]-pr[j+1];
				break;
			}
		}
	}
	for(int i=0;i<n-1;i++){
		assert(ans_sum[i]<=ans_sum[i+1]);
	}
	cout<<ans[n-1];
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -