#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:
ll mx;
ll v;
Node() {
mx = 0, v = 0;
}
};
Node indt[1200000];
void update(int st, int en, int S, int E, int n, ll v) {
if (st == S && en == E) {
indt[n].mx += v;
indt[n].v += v;
return;
}
int M = (S + E) / 2;
if (indt[n].v) {
indt[2 * n].mx += indt[n].v;
indt[2 * n].v += indt[n].v;
indt[2 * n + 1].mx += indt[n].v;
indt[2 * n + 1].v += indt[n].v;
indt[n].v = 0;
}
if (en <= M) update(st, en, S, M, 2 * n, v);
else if (st > M) update(st, en, M + 1, E, 2 * n + 1, v);
else {
update(st, M, S, M, 2 * n, v);
update(M + 1, en, M + 1, E, 2 * n + 1, v);
}
indt[n].mx = max(indt[2 * n].mx, indt[2 * n + 1].mx);
}
vector <pair<pll, pll>> Vq;
vector <ll> Vx;
vector <ll> Vy;
ll Qu[100050][3];
int main() {
int N, i;
ll L, R;
ll t1, t2, t3;
scanf("%d %lld %lld", &N, &L, &R);
for(i = 1; i <= N; i++) {
scanf("%lld %lld %lld", &t1, &t2, &t3);
Qu[i][0] = t1, Qu[i][1] = t2, Qu[i][2] = t3;
Vx.push_back(t1 - L + 1);
Vx.push_back(t1 + L);
Vx.push_back(t1 - R);
Vx.push_back(t1 + R + 1);
Vy.push_back(t2 - L + 1);
Vy.push_back(t2 + L);
Vy.push_back(t2 - R);
Vy.push_back(t2 + R + 1);
}
sort(all(Vx));
sort(all(Vy));
Vx.erase(unique(all(Vx)), Vx.end());
Vy.erase(unique(all(Vy)), Vy.end());
for (i = 1; i <= N; i++) {
ll t1 = Qu[i][0], t2 = Qu[i][1], t3 = Qu[i][2];
int sx = lower_bound(all(Vx), t1 - R) - Vx.begin() + 1;
int ex = lower_bound(all(Vx), t1 + R + 1) - Vx.begin();
int sy = lower_bound(all(Vy), t2 - R) - Vy.begin() + 1;
int ey = lower_bound(all(Vy), t2 + R + 1) - Vy.begin();
Vq.emplace_back(pll(sx, t3), pll(sy, ey));
Vq.emplace_back(pll(ex + 1, -t3), pll(sy, ey));
sx = lower_bound(all(Vx), t1 - L + 1) - Vx.begin() + 1;
ex = lower_bound(all(Vx), t1 + L) - Vx.begin();
sy = lower_bound(all(Vy), t2 - L + 1) - Vy.begin() + 1;
ey = lower_bound(all(Vy), t2 + L) - Vy.begin();
Vq.emplace_back(pll(sx, -t3), pll(sy, ey));
Vq.emplace_back(pll(ex + 1, t3), pll(sy, ey));
}
sort(all(Vq));
ll ans = 0;
for (i = 0; i < Vq.size(); i++) {
int sy = Vq[i].second.first;
int ey = Vq[i].second.second;
ll v = Vq[i].first.second;
update(sy, ey, 1, IT_MAX, 1, v);
if (i + 1 == Vq.size() || Vq[i].first.first != Vq[i + 1].first.first) ans = max(ans, indt[1].mx);
}
return !printf("%lld\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:138:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < Vq.size(); i++) {
^
DE.cpp:144: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:98:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %lld %lld", &N, &L, &R);
^
DE.cpp:100:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld", &t1, &t2, &t3);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
23120 KB |
Output is correct |
2 |
Correct |
3 ms |
23120 KB |
Output is correct |
3 |
Correct |
6 ms |
23120 KB |
Output is correct |
4 |
Correct |
6 ms |
23120 KB |
Output is correct |
5 |
Correct |
3 ms |
23120 KB |
Output is correct |
6 |
Correct |
3 ms |
23276 KB |
Output is correct |
7 |
Correct |
0 ms |
23264 KB |
Output is correct |
8 |
Correct |
6 ms |
23264 KB |
Output is correct |
9 |
Correct |
3 ms |
23412 KB |
Output is correct |
10 |
Correct |
3 ms |
23412 KB |
Output is correct |
11 |
Correct |
3 ms |
23412 KB |
Output is correct |
12 |
Correct |
3 ms |
23412 KB |
Output is correct |
13 |
Correct |
6 ms |
23412 KB |
Output is correct |
14 |
Correct |
6 ms |
23412 KB |
Output is correct |
15 |
Correct |
6 ms |
23412 KB |
Output is correct |
16 |
Correct |
0 ms |
23412 KB |
Output is correct |
17 |
Correct |
6 ms |
23412 KB |
Output is correct |
18 |
Correct |
3 ms |
23412 KB |
Output is correct |
19 |
Correct |
3 ms |
23412 KB |
Output is correct |
20 |
Correct |
9 ms |
23412 KB |
Output is correct |
21 |
Correct |
9 ms |
23412 KB |
Output is correct |
22 |
Correct |
6 ms |
23412 KB |
Output is correct |
23 |
Correct |
9 ms |
23412 KB |
Output is correct |
24 |
Correct |
3 ms |
23412 KB |
Output is correct |
25 |
Correct |
3 ms |
23412 KB |
Output is correct |
26 |
Correct |
3 ms |
23412 KB |
Output is correct |
27 |
Correct |
3 ms |
23412 KB |
Output is correct |
28 |
Correct |
0 ms |
23412 KB |
Output is correct |
29 |
Correct |
6 ms |
23412 KB |
Output is correct |
30 |
Correct |
6 ms |
23412 KB |
Output is correct |
31 |
Correct |
9 ms |
23412 KB |
Output is correct |
32 |
Correct |
6 ms |
23412 KB |
Output is correct |
33 |
Correct |
6 ms |
23412 KB |
Output is correct |
34 |
Correct |
9 ms |
23412 KB |
Output is correct |
35 |
Correct |
9 ms |
23412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
23120 KB |
Output is correct |
2 |
Correct |
3 ms |
23120 KB |
Output is correct |
3 |
Correct |
6 ms |
23120 KB |
Output is correct |
4 |
Correct |
6 ms |
23120 KB |
Output is correct |
5 |
Correct |
3 ms |
23120 KB |
Output is correct |
6 |
Correct |
3 ms |
23276 KB |
Output is correct |
7 |
Correct |
0 ms |
23264 KB |
Output is correct |
8 |
Correct |
6 ms |
23264 KB |
Output is correct |
9 |
Correct |
3 ms |
23412 KB |
Output is correct |
10 |
Correct |
3 ms |
23412 KB |
Output is correct |
11 |
Correct |
3 ms |
23412 KB |
Output is correct |
12 |
Correct |
3 ms |
23412 KB |
Output is correct |
13 |
Correct |
6 ms |
23412 KB |
Output is correct |
14 |
Correct |
6 ms |
23412 KB |
Output is correct |
15 |
Correct |
6 ms |
23412 KB |
Output is correct |
16 |
Correct |
0 ms |
23412 KB |
Output is correct |
17 |
Correct |
6 ms |
23412 KB |
Output is correct |
18 |
Correct |
3 ms |
23412 KB |
Output is correct |
19 |
Correct |
3 ms |
23412 KB |
Output is correct |
20 |
Correct |
9 ms |
23412 KB |
Output is correct |
21 |
Correct |
9 ms |
23412 KB |
Output is correct |
22 |
Correct |
6 ms |
23412 KB |
Output is correct |
23 |
Correct |
9 ms |
23412 KB |
Output is correct |
24 |
Correct |
3 ms |
23412 KB |
Output is correct |
25 |
Correct |
3 ms |
23412 KB |
Output is correct |
26 |
Correct |
3 ms |
23412 KB |
Output is correct |
27 |
Correct |
3 ms |
23412 KB |
Output is correct |
28 |
Correct |
0 ms |
23412 KB |
Output is correct |
29 |
Correct |
6 ms |
23412 KB |
Output is correct |
30 |
Correct |
6 ms |
23412 KB |
Output is correct |
31 |
Correct |
9 ms |
23412 KB |
Output is correct |
32 |
Correct |
6 ms |
23412 KB |
Output is correct |
33 |
Correct |
6 ms |
23412 KB |
Output is correct |
34 |
Correct |
9 ms |
23412 KB |
Output is correct |
35 |
Correct |
9 ms |
23412 KB |
Output is correct |
36 |
Correct |
0 ms |
23120 KB |
Output is correct |
37 |
Correct |
3 ms |
23264 KB |
Output is correct |
38 |
Correct |
3 ms |
23732 KB |
Output is correct |
39 |
Correct |
13 ms |
23732 KB |
Output is correct |
40 |
Correct |
13 ms |
24232 KB |
Output is correct |
41 |
Correct |
19 ms |
25260 KB |
Output is correct |
42 |
Correct |
33 ms |
25260 KB |
Output is correct |
43 |
Correct |
36 ms |
25260 KB |
Output is correct |
44 |
Correct |
53 ms |
27308 KB |
Output is correct |
45 |
Correct |
59 ms |
27308 KB |
Output is correct |
46 |
Correct |
99 ms |
27308 KB |
Output is correct |
47 |
Correct |
119 ms |
31404 KB |
Output is correct |
48 |
Correct |
123 ms |
31404 KB |
Output is correct |
49 |
Correct |
366 ms |
39596 KB |
Output is correct |
50 |
Correct |
406 ms |
39596 KB |
Output is correct |
51 |
Correct |
736 ms |
55980 KB |
Output is correct |
52 |
Correct |
749 ms |
55980 KB |
Output is correct |
53 |
Correct |
743 ms |
55980 KB |
Output is correct |
54 |
Correct |
706 ms |
55980 KB |
Output is correct |
55 |
Correct |
776 ms |
55980 KB |
Output is correct |
56 |
Correct |
779 ms |
55980 KB |
Output is correct |
57 |
Correct |
799 ms |
55980 KB |
Output is correct |
58 |
Correct |
783 ms |
55980 KB |
Output is correct |
59 |
Correct |
696 ms |
55980 KB |
Output is correct |
60 |
Correct |
763 ms |
55980 KB |
Output is correct |
61 |
Correct |
13 ms |
23732 KB |
Output is correct |
62 |
Correct |
73 ms |
27308 KB |
Output is correct |
63 |
Correct |
156 ms |
31404 KB |
Output is correct |
64 |
Correct |
336 ms |
39596 KB |
Output is correct |
65 |
Correct |
759 ms |
55980 KB |
Output is correct |
66 |
Correct |
483 ms |
55980 KB |
Output is correct |
67 |
Correct |
486 ms |
55980 KB |
Output is correct |
68 |
Correct |
426 ms |
55980 KB |
Output is correct |
69 |
Correct |
509 ms |
55980 KB |
Output is correct |
70 |
Correct |
473 ms |
55980 KB |
Output is correct |
71 |
Correct |
469 ms |
55980 KB |
Output is correct |
72 |
Correct |
516 ms |
55980 KB |
Output is correct |
73 |
Correct |
543 ms |
55980 KB |
Output is correct |
74 |
Correct |
553 ms |
55980 KB |
Output is correct |
75 |
Correct |
543 ms |
55980 KB |
Output is correct |
76 |
Correct |
576 ms |
55980 KB |
Output is correct |
77 |
Correct |
586 ms |
55980 KB |
Output is correct |
78 |
Correct |
596 ms |
55980 KB |
Output is correct |
79 |
Correct |
603 ms |
55980 KB |
Output is correct |
80 |
Correct |
613 ms |
55980 KB |
Output is correct |