답안 #200504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200504 2020-02-07T03:00:00 Z a1_N Bigger segments (IZhO19_segments) C++14
0 / 100
5 ms 380 KB
#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

const int N = 5e5 + 5;

int n,a[N];

long long pref[N];

pair<long long,long long> dp[N];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}
	dp[1] = {1,a[1]};
	for(int i = 2; i <= n; i++){
		for(int j = i - 1; j >= 1; j--){
			if(pref[i] - pref[j] >= dp[j].S && dp[i].F < dp[j].F + 1){
				dp[i] = {dp[j].F + 1,pref[i] - pref[j]};
			}
		}
	}
	cout << dp[n].F;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -