이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops, O3")
#pragma GCC target("avx2")
using namespace std;
const int N = 5e5 + 5;
long long pre[N], ans;
int n, m, nums[N], dp[N], par[N], id;
signed main () {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
m = n+1;
for (int i = 1; i < m; i++) cin >> nums[i];
for (int i = 1; i < m; i++) pre[i] += pre[i-1] + nums[i];
for (int i = 1; i < m; i++) {
int&p = par[i]; p = max(p, par[i-1]);
dp[i] = dp[p]+1;
id = lower_bound(pre, pre+m, pre[i]*2-pre[p])-pre;
par[id] = max(par[id], i);
}
ans = dp[n];
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
segments.cpp:2:40: warning: bad option '-f O3' to pragma 'optimize' [-Wpragmas]
2 | #pragma GCC optimize("unroll-loops, O3")
| ^
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
3 | #pragma GCC target("avx2")
| ^
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
segments.cpp:3:26: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
/v
# | 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... |