Submission #66889102
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define KI_MAX (1 << 19) /* 524288 */
int ki[KI_MAX * 2 - 1];
void ki_set(int pos, int value) {
pos += KI_MAX - 1;
ki[pos] = value;
do {
int a, b;
pos = (pos - 1) / 2;
a = ki[pos * 2 + 1];
b = ki[pos * 2 + 2];
ki[pos] = a >= b ? a : b;
} while (pos > 0);
}
int ki_get_i(int idx, int ss, int se, int qs, int qe) {
if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
return ki[idx];
} else if (se <= qs || qe <= ss) { /* 完全に外れている */
return -1;
} else {
int sm = ss + (se - ss) / 2;
int l = ki_get_i(idx * 2 + 1, ss, sm, qs, qe);
int r = ki_get_i(idx * 2 + 2, sm, se, qs, qe);
return l >= r ? l : r;
}
}
int ki_get(int qs, int qe) {
return ki_get_i(0, 0, KI_MAX, qs, qe);
}
int N, D, R;
int H[512345];
struct idxpos_s {
int idx, pos;
} idxpos[512345];
/* pos (H) の昇順 */
int cmp(const void* x, const void* y) {
struct idxpos_s a = *(const struct idxpos_s*)x, b = *(const struct idxpos_s*)y;
return a.pos < b.pos ? -1 : a.pos > b.pos;
}
int eachans[512345];
int main(void) {
int i;
int ans = 0;
if (scanf("%d%d%d", &N, &D, &R) != 3) return 1;
for (i = 0; i < N; i++) {
if (scanf("%d", &H[i]) != 1) return 1;
idxpos[i].idx = i;
idxpos[i].pos = H[i];
}
qsort(idxpos, N, sizeof(*idxpos), cmp);
/* すべての移動先を -1 に初期化する */
memset(ki, -1, sizeof(ki));
for (i = 0; i < N; i++) {
/* D 個前の足場を移動可能な場所として加える */
if (i - D >= 0) {
ki_set(idxpos[i - D].idx, eachans[i - D]);
}
eachans[i] = ki_get(idxpos[i].idx - R, idxpos[i].idx + R + 1) + 1;
if (eachans[i] > ans) ans = eachans[i];
}
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
F - Athletic |
User |
mikecat |
Language |
C (gcc 12.2.0) |
Score |
500 |
Code Size |
1829 Byte |
Status |
AC |
Exec Time |
282 ms |
Memory |
13704 KiB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
2 ms |
5812 KiB |
00_sample_01.txt |
AC |
2 ms |
5704 KiB |
01_test_00.txt |
AC |
2 ms |
5756 KiB |
01_test_01.txt |
AC |
2 ms |
5732 KiB |
01_test_02.txt |
AC |
2 ms |
5732 KiB |
01_test_03.txt |
AC |
2 ms |
5736 KiB |
01_test_04.txt |
AC |
2 ms |
5920 KiB |
01_test_05.txt |
AC |
3 ms |
5888 KiB |
01_test_06.txt |
AC |
137 ms |
10068 KiB |
01_test_07.txt |
AC |
282 ms |
13620 KiB |
01_test_08.txt |
AC |
67 ms |
7892 KiB |
01_test_09.txt |
AC |
48 ms |
7204 KiB |
01_test_10.txt |
AC |
68 ms |
8160 KiB |
01_test_11.txt |
AC |
203 ms |
12596 KiB |
01_test_12.txt |
AC |
78 ms |
8648 KiB |
01_test_13.txt |
AC |
5 ms |
6000 KiB |
01_test_14.txt |
AC |
55 ms |
7760 KiB |
01_test_15.txt |
AC |
38 ms |
7108 KiB |
01_test_16.txt |
AC |
163 ms |
10852 KiB |
01_test_17.txt |
AC |
203 ms |
11972 KiB |
01_test_18.txt |
AC |
231 ms |
13540 KiB |
01_test_19.txt |
AC |
279 ms |
13700 KiB |
01_test_20.txt |
AC |
155 ms |
13664 KiB |
01_test_21.txt |
AC |
272 ms |
13652 KiB |
01_test_22.txt |
AC |
165 ms |
13484 KiB |
01_test_23.txt |
AC |
277 ms |
13636 KiB |
01_test_24.txt |
AC |
130 ms |
13548 KiB |
01_test_25.txt |
AC |
107 ms |
13540 KiB |
01_test_26.txt |
AC |
107 ms |
13664 KiB |
01_test_27.txt |
AC |
143 ms |
13540 KiB |
01_test_28.txt |
AC |
147 ms |
13656 KiB |
01_test_29.txt |
AC |
75 ms |
13540 KiB |
01_test_30.txt |
AC |
207 ms |
13652 KiB |
01_test_31.txt |
AC |
208 ms |
13496 KiB |
01_test_32.txt |
AC |
204 ms |
13704 KiB |
01_test_33.txt |
AC |
205 ms |
13704 KiB |
01_test_34.txt |
AC |
208 ms |
13544 KiB |
01_test_35.txt |
AC |
201 ms |
13544 KiB |
01_test_36.txt |
AC |
2 ms |
5844 KiB |