#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
typedef long long lld;
const lld MINF = -2000000000;
struct intv {
lld x, yl, yr; int sco;
intv(lld x_=0, lld yl_=0, lld yr_=0, int sco_=0){ x=x_, yl=yl_, yr=yr_, sco=sco_; }
bool operator< (const intv& c) const {
if(x == c.x)return sco < c.sco;
return x<c.x;
}
} ba[404000];
struct iix {
int sum, mx;
iix(int sum_=0, int mx_=0) : sum(sum_), mx(mx_) {}
};
struct segtr {
segtr *l, *r; lld s, e;
iix key;
segtr(lld s_=0, lld e_=0) : s(s_), e(e_) {l=NULL, r=NULL;}
} *itr;
int N, bcn, dap;
lld L, R;
void add(segtr* it, lld mi, lld mx, int v){
if(mi > mx)return;
lld l = it->s, r = it->e;
lld m = ((l-MINF)+(r-MINF))/2 + MINF;
if(m == r && l < m)m--;
// printf("%lld %lld %lld / %lld %lld\n", l, m, r, mi, mx);
if(l == -1 && r == -1 && mi == 0)exit(0);
if(l == mi && r == mx){
it->key.sum += v;
it->key.mx += v;
return;
}
if(it->l == NULL)it->l = new segtr(l, m);
if(it->r == NULL)it->r = new segtr(m+1, r);
if(mx <= m) add(it->l, mi, mx, v);
else if(mi > m) add(it->r, mi, mx, v);
else{
add(it->l, mi, m, v);
add(it->r, m+1, mx, v);
}
it->key.mx = max(it->l->key.mx, it->r->key.mx) + it->key.sum;
}
int main(){
itr = new segtr;
itr->s = -2000000000, itr->e = 2000000000;
scanf("%d %lld %lld", &N, &L, &R); L--;
for(int i=0; i<N; i++){
lld x, y; int s;
scanf("%lld%lld%d", &x, &y, &s);
ba[bcn++] = intv(x-R, y-R, y+R, s);
ba[bcn++] = intv(x-L, y-L, y+L, -s);
ba[bcn++] = intv(x+L+1, y-L, y+L, s);
ba[bcn++] = intv(x+R+1, y-R, y+R, -s);
}
sort(ba, ba+bcn);
for(int i=0; i<bcn; i++){
add(itr, ba[i].yl, ba[i].yr, ba[i].sco);
int mx = itr->key.mx;
if(dap < mx)dap = mx;
}
printf("%d", dap);
return 0;
}
Compilation message
DE.cpp: In function 'int main()':
DE.cpp:59: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); L--;
^
DE.cpp:62:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%d", &x, &y, &s);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
13800 KB |
Output is correct |
2 |
Correct |
3 ms |
13800 KB |
Output is correct |
3 |
Correct |
0 ms |
13800 KB |
Output is correct |
4 |
Correct |
0 ms |
13932 KB |
Output is correct |
5 |
Correct |
6 ms |
13932 KB |
Output is correct |
6 |
Correct |
0 ms |
13932 KB |
Output is correct |
7 |
Correct |
3 ms |
13932 KB |
Output is correct |
8 |
Correct |
3 ms |
14064 KB |
Output is correct |
9 |
Correct |
3 ms |
14064 KB |
Output is correct |
10 |
Correct |
6 ms |
14064 KB |
Output is correct |
11 |
Correct |
3 ms |
14064 KB |
Output is correct |
12 |
Correct |
6 ms |
14064 KB |
Output is correct |
13 |
Correct |
0 ms |
13932 KB |
Output is correct |
14 |
Correct |
0 ms |
14064 KB |
Output is correct |
15 |
Correct |
0 ms |
13932 KB |
Output is correct |
16 |
Correct |
6 ms |
14064 KB |
Output is correct |
17 |
Correct |
6 ms |
13932 KB |
Output is correct |
18 |
Correct |
6 ms |
14064 KB |
Output is correct |
19 |
Correct |
6 ms |
13932 KB |
Output is correct |
20 |
Correct |
9 ms |
13932 KB |
Output is correct |
21 |
Correct |
6 ms |
14064 KB |
Output is correct |
22 |
Correct |
9 ms |
14064 KB |
Output is correct |
23 |
Correct |
3 ms |
14064 KB |
Output is correct |
24 |
Correct |
3 ms |
14064 KB |
Output is correct |
25 |
Correct |
6 ms |
14064 KB |
Output is correct |
26 |
Correct |
9 ms |
14064 KB |
Output is correct |
27 |
Correct |
3 ms |
14064 KB |
Output is correct |
28 |
Correct |
6 ms |
14064 KB |
Output is correct |
29 |
Correct |
3 ms |
13932 KB |
Output is correct |
30 |
Correct |
3 ms |
13932 KB |
Output is correct |
31 |
Correct |
9 ms |
13932 KB |
Output is correct |
32 |
Correct |
6 ms |
13932 KB |
Output is correct |
33 |
Correct |
3 ms |
13932 KB |
Output is correct |
34 |
Correct |
6 ms |
13932 KB |
Output is correct |
35 |
Correct |
3 ms |
13932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
13800 KB |
Output is correct |
2 |
Correct |
3 ms |
13800 KB |
Output is correct |
3 |
Correct |
0 ms |
13800 KB |
Output is correct |
4 |
Correct |
0 ms |
13932 KB |
Output is correct |
5 |
Correct |
6 ms |
13932 KB |
Output is correct |
6 |
Correct |
0 ms |
13932 KB |
Output is correct |
7 |
Correct |
3 ms |
13932 KB |
Output is correct |
8 |
Correct |
3 ms |
14064 KB |
Output is correct |
9 |
Correct |
3 ms |
14064 KB |
Output is correct |
10 |
Correct |
6 ms |
14064 KB |
Output is correct |
11 |
Correct |
3 ms |
14064 KB |
Output is correct |
12 |
Correct |
6 ms |
14064 KB |
Output is correct |
13 |
Correct |
0 ms |
13932 KB |
Output is correct |
14 |
Correct |
0 ms |
14064 KB |
Output is correct |
15 |
Correct |
0 ms |
13932 KB |
Output is correct |
16 |
Correct |
6 ms |
14064 KB |
Output is correct |
17 |
Correct |
6 ms |
13932 KB |
Output is correct |
18 |
Correct |
6 ms |
14064 KB |
Output is correct |
19 |
Correct |
6 ms |
13932 KB |
Output is correct |
20 |
Correct |
9 ms |
13932 KB |
Output is correct |
21 |
Correct |
6 ms |
14064 KB |
Output is correct |
22 |
Correct |
9 ms |
14064 KB |
Output is correct |
23 |
Correct |
3 ms |
14064 KB |
Output is correct |
24 |
Correct |
3 ms |
14064 KB |
Output is correct |
25 |
Correct |
6 ms |
14064 KB |
Output is correct |
26 |
Correct |
9 ms |
14064 KB |
Output is correct |
27 |
Correct |
3 ms |
14064 KB |
Output is correct |
28 |
Correct |
6 ms |
14064 KB |
Output is correct |
29 |
Correct |
3 ms |
13932 KB |
Output is correct |
30 |
Correct |
3 ms |
13932 KB |
Output is correct |
31 |
Correct |
9 ms |
13932 KB |
Output is correct |
32 |
Correct |
6 ms |
13932 KB |
Output is correct |
33 |
Correct |
3 ms |
13932 KB |
Output is correct |
34 |
Correct |
6 ms |
13932 KB |
Output is correct |
35 |
Correct |
3 ms |
13932 KB |
Output is correct |
36 |
Correct |
3 ms |
14856 KB |
Output is correct |
37 |
Correct |
3 ms |
17628 KB |
Output is correct |
38 |
Correct |
16 ms |
21588 KB |
Output is correct |
39 |
Correct |
29 ms |
27264 KB |
Output is correct |
40 |
Correct |
46 ms |
33732 KB |
Output is correct |
41 |
Correct |
46 ms |
41784 KB |
Output is correct |
42 |
Correct |
126 ms |
50760 KB |
Output is correct |
43 |
Correct |
136 ms |
61584 KB |
Output is correct |
44 |
Correct |
173 ms |
72540 KB |
Output is correct |
45 |
Correct |
223 ms |
83496 KB |
Output is correct |
46 |
Correct |
279 ms |
98544 KB |
Output is correct |
47 |
Correct |
329 ms |
110688 KB |
Output is correct |
48 |
Correct |
369 ms |
127980 KB |
Output is correct |
49 |
Correct |
1022 ms |
279516 KB |
Output is correct |
50 |
Correct |
1079 ms |
288360 KB |
Output is correct |
51 |
Execution timed out |
1500 ms |
442404 KB |
Execution timed out |
52 |
Halted |
0 ms |
0 KB |
- |