# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
501798 | dxz05 | Bigger segments (IZhO19_segments) | C++14 | 15 ms | 3220 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MP make_pair
pair<int, ll> dp[3001];
void chmax(pair<int, ll> &x, pair<int, ll> y){
if (x.first < y.first || x.first == y.first && x.second > y.second) x = y;
}
int a[500005];
ll pref[500005];
ll sum(int l, int r){
return pref[r] - pref[l - 1];
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n;
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
pref[i] = pref[i - 1] + a[i];
}
dp[0] = MP(0, 0ll);
for (int i = 1; i <= n; i++){
for (int j = 0; j < i; j++){
if (sum(j + 1, i) >= dp[j].second) chmax(dp[i], MP(dp[j].first + 1, sum(j + 1, i)));
}
// cout << dp[i].first << ' ' << dp[i].second << endl;
}
cout << dp[n].first;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |