#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1034567890123456789ll;
const db PI = acos(-1);
const db ERR = 1E-11;
class Node {
public:
int mx, v;
Node() { mx = 0, v = 0; }
};
Node indt[1100000];
void update(int st, int en, int S, int E, int n, int v) {
if (st > en) return;
if (st == S && en == E) {
indt[n].mx += v;
indt[n].v += v;
return;
}
int M = (S + E) / 2;
update(st, min(en, M), S, M, 2 * n, v);
update(max(M + 1, st), en, M + 1, E, 2 * n + 1, v);
indt[n].mx = indt[n].v + max(indt[2 * n].mx, indt[2 * n + 1].mx);
}
vector <pair<pii, pii>> Vq;
vector <int> Vy;
int main() {
int N, L, R, i;
scanf("%d %d %d", &N, &L, &R);
while (N--) {
int t1, t2, t3;
scanf("%d %d %d", &t1, &t2, &t3);
Vq.emplace_back(pii(t1 - R, t3), pii(t2 - R, t2 + R + 1));
Vq.emplace_back(pii(t1 + R + 1, -t3), pii(t2 - R, t2 + R + 1));
Vq.emplace_back(pii(t1 - L + 1, -t3), pii(t2 - L + 1, t2 + L));
Vq.emplace_back(pii(t1 + L, t3), pii(t2 - L + 1, t2 + L));
Vy.push_back(t2 - R);
Vy.push_back(t2 + R + 1);
Vy.push_back(t2 - L + 1);
Vy.push_back(t2 + L);
}
sort(all(Vy));
Vy.erase(unique(all(Vy)), Vy.end());
for (auto &it : Vq) {
it.second.first = lower_bound(all(Vy), it.second.first) - Vy.begin() + 1;
it.second.second = lower_bound(all(Vy), it.second.second) - Vy.begin();
}
sort(all(Vq));
int ans = 0;
for (i = 0; i < Vq.size(); i++) {
int t1 = Vq[i].first.first, t2 = Vq[i].first.second, t3 = Vq[i].second.first, t4 = Vq[i].second.second;
update(t3, t4, 1, IT_MAX, 1, t2);
if (i + 1 == Vq.size() || Vq[i].first.first != Vq[i + 1].first.first) ans = max(ans, indt[1].mx);
}
return !printf("%d\n", ans);
}
Compilation message
DE.cpp:22:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
^
DE.cpp:23:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:336777216")
^
DE.cpp: In function 'int main()':
DE.cpp:101:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < Vq.size(); i++) {
^
DE.cpp:104:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i + 1 == Vq.size() || Vq[i].first.first != Vq[i + 1].first.first) ans = max(ans, indt[1].mx);
^
DE.cpp:102:7: warning: unused variable 't1' [-Wunused-variable]
int t1 = Vq[i].first.first, t2 = Vq[i].first.second, t3 = Vq[i].second.first, t4 = Vq[i].second.second;
^
DE.cpp:76:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &N, &L, &R);
^
DE.cpp:79:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &t1, &t2, &t3);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
10616 KB |
Output is correct |
2 |
Correct |
3 ms |
10616 KB |
Output is correct |
3 |
Correct |
6 ms |
10616 KB |
Output is correct |
4 |
Correct |
0 ms |
10616 KB |
Output is correct |
5 |
Correct |
0 ms |
10616 KB |
Output is correct |
6 |
Correct |
6 ms |
10616 KB |
Output is correct |
7 |
Correct |
0 ms |
10756 KB |
Output is correct |
8 |
Correct |
0 ms |
10756 KB |
Output is correct |
9 |
Correct |
6 ms |
10756 KB |
Output is correct |
10 |
Correct |
3 ms |
10756 KB |
Output is correct |
11 |
Correct |
3 ms |
10756 KB |
Output is correct |
12 |
Correct |
6 ms |
10756 KB |
Output is correct |
13 |
Correct |
3 ms |
10756 KB |
Output is correct |
14 |
Correct |
0 ms |
10756 KB |
Output is correct |
15 |
Correct |
3 ms |
10756 KB |
Output is correct |
16 |
Correct |
3 ms |
10756 KB |
Output is correct |
17 |
Correct |
0 ms |
10756 KB |
Output is correct |
18 |
Correct |
3 ms |
10756 KB |
Output is correct |
19 |
Correct |
3 ms |
10756 KB |
Output is correct |
20 |
Correct |
3 ms |
10756 KB |
Output is correct |
21 |
Correct |
6 ms |
10756 KB |
Output is correct |
22 |
Correct |
6 ms |
10756 KB |
Output is correct |
23 |
Correct |
3 ms |
10756 KB |
Output is correct |
24 |
Correct |
6 ms |
10756 KB |
Output is correct |
25 |
Correct |
6 ms |
10756 KB |
Output is correct |
26 |
Correct |
3 ms |
10756 KB |
Output is correct |
27 |
Correct |
3 ms |
10756 KB |
Output is correct |
28 |
Correct |
3 ms |
10756 KB |
Output is correct |
29 |
Correct |
9 ms |
10756 KB |
Output is correct |
30 |
Correct |
3 ms |
10756 KB |
Output is correct |
31 |
Correct |
3 ms |
10756 KB |
Output is correct |
32 |
Correct |
3 ms |
10756 KB |
Output is correct |
33 |
Correct |
6 ms |
10756 KB |
Output is correct |
34 |
Correct |
0 ms |
10756 KB |
Output is correct |
35 |
Correct |
0 ms |
10756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
10616 KB |
Output is correct |
2 |
Correct |
3 ms |
10616 KB |
Output is correct |
3 |
Correct |
6 ms |
10616 KB |
Output is correct |
4 |
Correct |
0 ms |
10616 KB |
Output is correct |
5 |
Correct |
0 ms |
10616 KB |
Output is correct |
6 |
Correct |
6 ms |
10616 KB |
Output is correct |
7 |
Correct |
0 ms |
10756 KB |
Output is correct |
8 |
Correct |
0 ms |
10756 KB |
Output is correct |
9 |
Correct |
6 ms |
10756 KB |
Output is correct |
10 |
Correct |
3 ms |
10756 KB |
Output is correct |
11 |
Correct |
3 ms |
10756 KB |
Output is correct |
12 |
Correct |
6 ms |
10756 KB |
Output is correct |
13 |
Correct |
3 ms |
10756 KB |
Output is correct |
14 |
Correct |
0 ms |
10756 KB |
Output is correct |
15 |
Correct |
3 ms |
10756 KB |
Output is correct |
16 |
Correct |
3 ms |
10756 KB |
Output is correct |
17 |
Correct |
0 ms |
10756 KB |
Output is correct |
18 |
Correct |
3 ms |
10756 KB |
Output is correct |
19 |
Correct |
3 ms |
10756 KB |
Output is correct |
20 |
Correct |
3 ms |
10756 KB |
Output is correct |
21 |
Correct |
6 ms |
10756 KB |
Output is correct |
22 |
Correct |
6 ms |
10756 KB |
Output is correct |
23 |
Correct |
3 ms |
10756 KB |
Output is correct |
24 |
Correct |
6 ms |
10756 KB |
Output is correct |
25 |
Correct |
6 ms |
10756 KB |
Output is correct |
26 |
Correct |
3 ms |
10756 KB |
Output is correct |
27 |
Correct |
3 ms |
10756 KB |
Output is correct |
28 |
Correct |
3 ms |
10756 KB |
Output is correct |
29 |
Correct |
9 ms |
10756 KB |
Output is correct |
30 |
Correct |
3 ms |
10756 KB |
Output is correct |
31 |
Correct |
3 ms |
10756 KB |
Output is correct |
32 |
Correct |
3 ms |
10756 KB |
Output is correct |
33 |
Correct |
6 ms |
10756 KB |
Output is correct |
34 |
Correct |
0 ms |
10756 KB |
Output is correct |
35 |
Correct |
0 ms |
10756 KB |
Output is correct |
36 |
Correct |
3 ms |
10616 KB |
Output is correct |
37 |
Correct |
3 ms |
10756 KB |
Output is correct |
38 |
Correct |
3 ms |
10888 KB |
Output is correct |
39 |
Correct |
9 ms |
10888 KB |
Output is correct |
40 |
Correct |
13 ms |
11116 KB |
Output is correct |
41 |
Correct |
26 ms |
11500 KB |
Output is correct |
42 |
Correct |
23 ms |
11500 KB |
Output is correct |
43 |
Correct |
33 ms |
11500 KB |
Output is correct |
44 |
Correct |
49 ms |
12492 KB |
Output is correct |
45 |
Correct |
56 ms |
12492 KB |
Output is correct |
46 |
Correct |
76 ms |
12492 KB |
Output is correct |
47 |
Correct |
76 ms |
14284 KB |
Output is correct |
48 |
Correct |
93 ms |
14284 KB |
Output is correct |
49 |
Correct |
296 ms |
17868 KB |
Output is correct |
50 |
Correct |
309 ms |
17868 KB |
Output is correct |
51 |
Correct |
589 ms |
25036 KB |
Output is correct |
52 |
Correct |
596 ms |
25036 KB |
Output is correct |
53 |
Correct |
583 ms |
25036 KB |
Output is correct |
54 |
Correct |
603 ms |
25036 KB |
Output is correct |
55 |
Correct |
596 ms |
25036 KB |
Output is correct |
56 |
Correct |
593 ms |
25036 KB |
Output is correct |
57 |
Correct |
589 ms |
25036 KB |
Output is correct |
58 |
Correct |
606 ms |
25036 KB |
Output is correct |
59 |
Correct |
573 ms |
25036 KB |
Output is correct |
60 |
Correct |
613 ms |
25036 KB |
Output is correct |
61 |
Correct |
6 ms |
10888 KB |
Output is correct |
62 |
Correct |
56 ms |
12492 KB |
Output is correct |
63 |
Correct |
116 ms |
14284 KB |
Output is correct |
64 |
Correct |
276 ms |
17868 KB |
Output is correct |
65 |
Correct |
599 ms |
25036 KB |
Output is correct |
66 |
Correct |
413 ms |
25036 KB |
Output is correct |
67 |
Correct |
413 ms |
25036 KB |
Output is correct |
68 |
Correct |
393 ms |
25036 KB |
Output is correct |
69 |
Correct |
406 ms |
25036 KB |
Output is correct |
70 |
Correct |
436 ms |
25036 KB |
Output is correct |
71 |
Correct |
413 ms |
25036 KB |
Output is correct |
72 |
Correct |
429 ms |
25036 KB |
Output is correct |
73 |
Correct |
456 ms |
25036 KB |
Output is correct |
74 |
Correct |
453 ms |
25036 KB |
Output is correct |
75 |
Correct |
469 ms |
25036 KB |
Output is correct |
76 |
Correct |
469 ms |
25036 KB |
Output is correct |
77 |
Correct |
486 ms |
25036 KB |
Output is correct |
78 |
Correct |
493 ms |
25036 KB |
Output is correct |
79 |
Correct |
469 ms |
25036 KB |
Output is correct |
80 |
Correct |
479 ms |
25036 KB |
Output is correct |