# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
550651 | rainboy | 빌딩 장식 3 (JOI15_building3) | C11 | 119 ms | 11952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N 1000000
int main() {
static int aa[N];
static char used[N + 1];
int n, h, i, j, a;
long long ans;
scanf("%d", &n);
for (i = 0; i < n - 1; i++)
scanf("%d", &aa[i]);
used[0] = 1;
a = 0;
for (i = 0; i < n - 1; i++) {
if (!used[aa[i] - 1]) {
if (a == 0)
a = aa[i];
else if (a != aa[i]) {
printf("0\n");
return 0;
}
}
used[aa[i]] = 1;
}
if (a == 0) {
ans = 1, a = 0;
for (i = 0; i < n - 1; i++) {
if (a + 1 == aa[i])
a++;
ans += a;
}
printf("%lld\n", ans);
return 0;
}
for (j = 0; j < n - 1; j++)
if (aa[j] == a)
break;
if (a == 2)
i = -1;
else
for (i = 0; i < n - 1; i++)
if (aa[i] == a - 2)
break;
if (i > j) {
printf("0\n");
return 0;
}
ans = 0;
for (h = i; h < j; h++)
if (h < 0 || aa[h] != a - 1)
ans++;
printf("%lld\n", ans);
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... |