提出 #49939140
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
namespace lzyqwq {
template<class T> void read(T &x) {
x = 0; T f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 48; x *= f;
}
template<class T> void write(T x) {
if (x > 9) write(x / 10); putchar(x % 10 + 48);
}
template<class T> void print(T x, char ed = '\n') {
if (x < 0) putchar('-'), x = -x; write(x), putchar(ed);
}
const int N = 5e5 + 5; int n, d, a[N], f[N], ans;
struct SegmentTree {
int a[N << 2];
int ls(int x) { return x << 1; } int rs(int x) { return x << 1 | 1; }
void mdf(int x, int l, int r, int k, int v) {
if (l == r) return void(a[x] = max(a[x], v));
int m = (l + r) >> 1;
if (k <= m) mdf(ls(x), l, m, k, v); else mdf(rs(x), m + 1, r, k, v);
a[x] = max(a[ls(x)], a[rs(x)]);
}
int qry(int x, int l, int r, int ql, int qr) {
if (ql > qr) return 0; if (ql <= l && r <= qr) return a[x];
int m = (l + r) >> 1, ret = 0;
if (ql <= m) ret = qry(ls(x), l, m, ql, qr);
if (qr > m) ret = max(ret, qry(rs(x), m + 1, r, ql, qr)); return ret;
}
} T;
void Main() {
read(n); read(d);
for (int i = 1; i <= n; ++i) {
read(a[i]);
f[i] = max(T.qry(1, 1, N, max(1, a[i] - d), a[i]),
T.qry(1, 1, N, min(a[i] + 1, N), min(a[i] + d, N))) + 1;
T.mdf(1, 1, N, a[i], f[i]); ans = max(ans, f[i]);
}
print(ans);
}
}
signed main() { return lzyqwq::Main(), 0; }
提出情報
コンパイルエラー
Main.cpp: In function ‘void lzyqwq::read(T&)’:
Main.cpp:7:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
7 | for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 48; x *= f;
| ^~~
Main.cpp:7:77: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
7 | for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - 48; x *= f;
| ^
Main.cpp: In function ‘void lzyqwq::write(T)’:
Main.cpp:10:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
10 | if (x > 9) write(x / 10); putchar(x % 10 + 48);
| ^~
Main.cpp:10:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
10 | if (x > 9) write(x / 10); putchar(x % 10 + 48);
| ^~~~~~~
Main.cpp: In function ‘void lzyqwq::print(T, char)’:
Main.cpp:13:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
13 | if (x < 0) putchar('-'), x = -x; write(x), putchar(ed);
| ^~
Main.cpp:13:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
13 | if (x < 0) putchar('-'), x = -x; write(x), putchar(ed);
| ^~~~~
Main.cpp: In member function ‘int lzyqwq::SegmentTree::qry(int, int, int, int, int)’:
Main.cpp:26:13: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
26 | if (ql > qr) return 0; if (ql <= l && r <= qr) return a[x];
| ^~
Main.cpp:26:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
26 | if (ql > qr) return 0; if (ql <= l && r <= qr) return a[x];
| ^~
Main.cpp:29:13: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
29 | if (qr > m) ret = max(ret, qry(rs(x), m + 1, r, ql, qr)); return ret;
| ^~
Main.cpp:29:71: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
29 | if (qr > m) ret = max(ret, qry(rs(x), m + 1, r, ql, qr)); return ret;
| ^~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
525 / 525 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample00.txt, sample01.txt, sample02.txt |
| All |
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt, testcase44.txt, testcase45.txt, testcase46.txt, testcase47.txt, testcase48.txt, testcase49.txt, testcase50.txt, testcase51.txt, testcase52.txt, testcase53.txt, testcase54.txt, testcase55.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample00.txt |
AC |
1 ms |
3536 KiB |
| sample01.txt |
AC |
1 ms |
3568 KiB |
| sample02.txt |
AC |
1 ms |
3516 KiB |
| testcase00.txt |
AC |
44 ms |
7396 KiB |
| testcase01.txt |
AC |
42 ms |
7516 KiB |
| testcase02.txt |
AC |
44 ms |
7424 KiB |
| testcase03.txt |
AC |
118 ms |
11468 KiB |
| testcase04.txt |
AC |
208 ms |
8952 KiB |
| testcase05.txt |
AC |
209 ms |
9120 KiB |
| testcase06.txt |
AC |
190 ms |
8728 KiB |
| testcase07.txt |
AC |
209 ms |
9120 KiB |
| testcase08.txt |
AC |
193 ms |
8740 KiB |
| testcase09.txt |
AC |
209 ms |
9028 KiB |
| testcase10.txt |
AC |
175 ms |
7420 KiB |
| testcase11.txt |
AC |
206 ms |
8720 KiB |
| testcase12.txt |
AC |
178 ms |
7540 KiB |
| testcase13.txt |
AC |
204 ms |
8588 KiB |
| testcase14.txt |
AC |
190 ms |
7980 KiB |
| testcase15.txt |
AC |
203 ms |
8452 KiB |
| testcase16.txt |
AC |
162 ms |
11372 KiB |
| testcase17.txt |
AC |
169 ms |
11492 KiB |
| testcase18.txt |
AC |
169 ms |
11368 KiB |
| testcase19.txt |
AC |
174 ms |
11536 KiB |
| testcase20.txt |
AC |
170 ms |
11432 KiB |
| testcase21.txt |
AC |
172 ms |
11472 KiB |
| testcase22.txt |
AC |
174 ms |
11456 KiB |
| testcase23.txt |
AC |
180 ms |
11468 KiB |
| testcase24.txt |
AC |
173 ms |
11272 KiB |
| testcase25.txt |
AC |
183 ms |
11476 KiB |
| testcase26.txt |
AC |
181 ms |
11236 KiB |
| testcase27.txt |
AC |
192 ms |
11420 KiB |
| testcase28.txt |
AC |
196 ms |
11212 KiB |
| testcase29.txt |
AC |
209 ms |
11372 KiB |
| testcase30.txt |
AC |
201 ms |
11112 KiB |
| testcase31.txt |
AC |
216 ms |
11460 KiB |
| testcase32.txt |
AC |
212 ms |
11296 KiB |
| testcase33.txt |
AC |
222 ms |
11440 KiB |
| testcase34.txt |
AC |
212 ms |
11400 KiB |
| testcase35.txt |
AC |
235 ms |
11428 KiB |
| testcase36.txt |
AC |
237 ms |
11360 KiB |
| testcase37.txt |
AC |
245 ms |
11576 KiB |
| testcase38.txt |
AC |
242 ms |
11356 KiB |
| testcase39.txt |
AC |
257 ms |
11536 KiB |
| testcase40.txt |
AC |
248 ms |
11400 KiB |
| testcase41.txt |
AC |
259 ms |
11464 KiB |
| testcase42.txt |
AC |
264 ms |
11428 KiB |
| testcase43.txt |
AC |
266 ms |
11444 KiB |
| testcase44.txt |
AC |
251 ms |
11284 KiB |
| testcase45.txt |
AC |
273 ms |
11444 KiB |
| testcase46.txt |
AC |
259 ms |
11280 KiB |
| testcase47.txt |
AC |
269 ms |
11448 KiB |
| testcase48.txt |
AC |
254 ms |
11344 KiB |
| testcase49.txt |
AC |
262 ms |
11472 KiB |
| testcase50.txt |
AC |
211 ms |
11192 KiB |
| testcase51.txt |
AC |
254 ms |
11532 KiB |
| testcase52.txt |
AC |
208 ms |
11616 KiB |
| testcase53.txt |
AC |
204 ms |
11464 KiB |
| testcase54.txt |
AC |
162 ms |
11148 KiB |
| testcase55.txt |
AC |
176 ms |
11464 KiB |