# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
382441 | BartolM | Bigger segments (IZhO19_segments) | C++17 | 121 ms | 18952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
const int INF=0x3f3f3f3f;
const ll MAX=(ll)INF*INF;
const int N=5e5+5;
int n;
ll pref[N], p[N], dp[N];
int lef[N];
void solve() {
pref[n+1]=MAX;
lef[0]=0; dp[0]=0;
for (int i=1; i<=n; ++i) {
lef[i]=max(lef[i], lef[i-1]);
dp[i]=dp[lef[i]]+1;
ll br=2*pref[i]-pref[lef[i]];
int nx=lower_bound(pref, pref+n+2, br)-pref;
lef[nx]=i;
}
printf("%lld\n", dp[n]);
}
void load() {
scanf("%d", &n);
for (int i=1; i<=n; ++i) {
scanf("%lld", &p[i]);
pref[i]=pref[i-1]+p[i];
}
}
int main() {
load();
solve();
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... |