| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 290449 | luciocf | Bigger segments (IZhO19_segments) | C++14 | 0 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5+10;
int n;
int a[maxn];
int qtd(int p)
{
ll ant = 0;
for (int i = 1; i <= p; i++)
ant += 1ll*a[i];
int at = p;
int ans = 1;
while (at < n)
{
++ans;
ll aux = 0;
int i;
for (i = at+1; i <= n; i++)
{
aux += 1ll*a[i];
if (aux >= ant) break;
}
if (i > n) return -1;
at = i;
ant = aux;
}
return ans;
}
int main(void)
{
scanf("%d", &n);
ll soma = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
soma += 1ll*a[i];
}
int ini = 1, fim = 1, ans = 1;
ll aux = 0;
for (int i = n; i >= 1; i--)
{
aux += 1ll*a[i];
if (soma-aux <= aux)
{
fim = i;
break;
}
}
while (ini <= fim)
{
int mid = (ini+fim)>>1;
if (qtd(mid) != -1) fim = mid-1, ans = qtd(mid);
else ini = mid+1;
}
printf("%d\n", ans);
}
컴파일 시 표준 에러 (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... | ||||
