#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
int n,l,r,y;
vector<pair<int,int>> eves;
int rez[nmax + 5];
int pint(double x)
{
if(x >= 0)
{
return (int)(x);
}
return (int)(x) - 1;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
cin>>n;
cin>>l>>r>>y;
for(int i=1; i<=n; i++)
{
int x,v,h;
cin>>x>>v>>h;
double st = 1.0 * y * (1.0 * -h / v) + x;
double dr = 1.0 * y * (1.0 * h / v) + x;
if(st >= r || dr <= l)
{
continue;
}
int st_ev = pint(st) + 1;
int dr_ev = 0;
if(pint(dr)==dr)
{
dr_ev = pint(dr);
}
else
{
dr_ev = pint(dr) + 1;
}
if(st_ev < l)
{
st_ev = l;
}
if(dr_ev > r)
{
dr_ev = r + 1;
}
eves.push_back({st_ev,+1});
eves.push_back({dr_ev,-1});
}
sort(eves.begin(),eves.end());
int last = l;
int cur = 0;
for(auto it : eves)
{
int poz = it.first;
int val = it.second;
rez[cur] += poz - last;
cur += val;
last = poz;
}
rez[cur] += r - last + 1;
for(int i=0;i<=n;i++)
{
if(i)
{
rez[i] += rez[i - 1];
}
cout<<rez[i]<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |