#include <bits/stdc++.h>
using namespace std;
double inters(double a, double b, double y){
double p = (y-b)/(double)a;
return p;
}
int main() {
long long count0[100005];
memset(count0,0,sizeof count0);
int n, l, r, y;
cin >> n >> l >> r >> y;
vector<pair<double,int>> pnts;
for(int i = 0;i<n;i++){
int x, v, h;
cin >> x >> v >> h;
double a = v/(double)h;
double b = -a*x;
pnts.push_back({inters(a,b,y),-1});
pnts.push_back({inters(-a,-b,y),1});
}
for(int i = 0;i<pnts.size();i++){
if(pnts[i].second == 1)pnts[i].first += 10e-6;
else pnts[i].first -= 10e-6;
}
sort(pnts.begin(), pnts.end());
int left = l, c = 0;
for(int i = 0; i < pnts.size(); i++){
if(pnts[i].first > r)break;
if(pnts[i].first < l){
if(pnts[i].second == 1)
c++;
else
c--;
continue;
}
count0[c] += ceil(pnts[i].first) - left;
if(pnts[i].second == 1)
c++;
else
c--;
left = ceil(pnts[i].first);
}
count0[c] += r - left + 1;
for(int i = 0; i <= n; i++){
if(i != 0)
count0[i] += count0[i-1];
cout << count0[i] << endl;
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i = 0;i<pnts.size();i++){
| ~^~~~~~~~~~~~
Main.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i = 0; i < pnts.size(); i++){
| ~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1076 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
223 ms |
6204 KB |
Output is correct |
4 |
Correct |
205 ms |
6344 KB |
Output is correct |
5 |
Correct |
214 ms |
6200 KB |
Output is correct |
6 |
Correct |
217 ms |
6360 KB |
Output is correct |
7 |
Correct |
183 ms |
5976 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1076 KB |
Output is correct |
2 |
Correct |
1 ms |
980 KB |
Output is correct |
3 |
Correct |
223 ms |
6204 KB |
Output is correct |
4 |
Correct |
205 ms |
6344 KB |
Output is correct |
5 |
Correct |
214 ms |
6200 KB |
Output is correct |
6 |
Correct |
217 ms |
6360 KB |
Output is correct |
7 |
Correct |
183 ms |
5976 KB |
Output is correct |
8 |
Correct |
1 ms |
980 KB |
Output is correct |
9 |
Correct |
242 ms |
6876 KB |
Output is correct |
10 |
Correct |
234 ms |
6984 KB |
Output is correct |
11 |
Correct |
265 ms |
6972 KB |
Output is correct |
12 |
Correct |
237 ms |
6876 KB |
Output is correct |
13 |
Correct |
191 ms |
6152 KB |
Output is correct |