#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
const ll inf = (1LL << 60);
int n;
ll l, r;
typedef tuple<ll,ll,ll,ll,ll> rect;
vector<rect> rs;
void in(){
scanf("%d%lld%lld", &n, &l, &r);
for(int i=1; i<=n; ++i){
ll x, y, s;
scanf("%lld%lld%lld", &x, &y, &s);
rs.emplace_back(x-2*r, x, y-2*r, y, s);
rs.emplace_back(x-r-l+1, x-(r-l)-1, y-r-l+1, y-(r-l)-1, -s);
}
}
vector<ll> YS;
int yn;
void compress(){
YS.pb(inf);
for(auto& tmp:rs){
int d=get<2>(tmp), u=get<3>(tmp);
YS.pb(d);
YS.pb(u+1);
}
sort(all(YS));
YS.erase(unique(all(YS)), YS.end());
yn=YS.size()-1;
}
typedef tuple<ll,ll,ll,ll> Q;
vector<Q> qs;
void make_query(){
qs.reserve(4*n);
for(auto& tmp:rs){
ll l,r,d,u,s; tie(l,r,d,u,s)=tmp;
d=lower_bound(all(YS), d) - YS.begin();
u=lower_bound(all(YS), u+1) - YS.begin() - 1;
qs.emplace_back(l, d, u, s);
qs.emplace_back(r+1, d, u, -s);
}
sort(all(qs));
}
struct SEG {
int N;
ll tmax[1048576];
ll lazy[1048576];
void init(int n){
N=n;
}
inline void pd(int p, int l, int r){
if(l==r) return;
ll d=lazy[p];
tmax[p*2] += d;
lazy[p*2] += d;
tmax[p*2+1] += d;
lazy[p*2+1] += d;
lazy[p]=0;
}
void update(int l, int r, int s, int p, int ml, int mr){
pd(p, ml, mr);
if(l<=ml && mr<=r){
tmax[p]+=s;
lazy[p]+=s;
return;
}
if(r<ml || mr<l) return;
int mid=(ml+mr)/2;
update(l,r,s, p*2, ml, mid);
update(l,r,s, p*2+1, mid+1, mr);
tmax[p]=max(tmax[p*2], tmax[p*2+1]);
}
ll get_max(){
return tmax[1];
}
} seg;
int main()
{
//freopen("in", "r", stdin);
in();
compress();
make_query();
seg.init(yn);
ll ans = 0;
ll last_x = -inf;
for(auto& q:qs){
ll x, d, u, s;
tie(x, d, u, s) = q;
if(last_x != x) ans=max(ans, seg.get_max());
last_x = x;
seg.update(d, u, s, 1, 0, yn-1);
}
printf("%lld\n", ans);
return 0;
}
Compilation message
DE.cpp:33:5: error: 'int yn' redeclared as different kind of symbol
int yn;
^
In file included from /usr/include/features.h:367:0,
from /usr/include/assert.h:35,
from /usr/include/c++/5/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:33,
from DE.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:252:1: note: previous declaration 'double yn(int, double)'
__MATHCALL (yn,, (int, _Mdouble_));
^
DE.cpp: In function 'void compress()':
DE.cpp:44:4: error: assignment of function 'double yn(int, double)'
yn=YS.size()-1;
^
DE.cpp:44:4: error: cannot convert 'std::vector<long long int>::size_type {aka long unsigned int}' to 'double(int, double) throw ()' in assignment
DE.cpp: In function 'int main()':
DE.cpp:107:13: error: invalid conversion from 'double (*)(int, double) throw ()' to 'int' [-fpermissive]
seg.init(yn);
^
DE.cpp:66:7: note: initializing argument 1 of 'void SEG::init(int)'
void init(int n){
^
DE.cpp:115:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
seg.update(d, u, s, 1, 0, yn-1);
^
DE.cpp:115:31: error: invalid conversion from 'double (*)(int, double) throw ()' to 'int' [-fpermissive]
seg.update(d, u, s, 1, 0, yn-1);
^
DE.cpp:80:7: note: initializing argument 6 of 'void SEG::update(int, int, int, int, int, int)'
void update(int l, int r, int s, int p, int ml, int mr){
^
DE.cpp: In function 'void read(int&)':
DE.cpp:6:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
void read(int& x){ scanf("%d",&x); }
^
DE.cpp: In function 'void read(ll&)':
DE.cpp:7:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
void read(ll& x){ scanf("%lld",&x); }
^
DE.cpp: In function 'void in()':
DE.cpp:23:33: 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:26:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%lld", &x, &y, &s);
^