This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sui cout.tie(NULL); cin.tie(NULL); ios_base::sync_with_stdio(false);
#define ll long long
#define pii pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define SZ(x) ((ll)(x).size())
const int N = 2e5+100;
ll n, l, r, x[N], ans[N];
long double v[N], h[N], y;
vector<pii> vec;
ll left(long double x) {
if (int(x) == x) return x;
if (x > 0) return int(x) + 1;
return int(x);
}
ll right(long double x) {
if (int(x) == x) return x+1;
if (x > 0) return int(x) + 1;
return int(x);
}
int main()
{
sui
cin >> n >> l >> r >> y;
ll open = 0;
for (int i = 0; i < n; i++) {
cin >> x[i] >> v[i] >> h[i];
long double m = v[i] / h[i];
if (m == 0) {
open++;
continue;
}
long double x1 = y/m + x[i];
long double x2 = y/(-m) + x[i];
if (left(x1) < (r+1))
vec.pb({left(x1), 0});
if (right(x2) > l)
vec.pb({right(x2), 1});
else open ++;
//cout << right(x2) << " " << left(x1) << endl;
}
vec.pb({l, 0});
vec.pb({r+1, 0});
sort(vec.begin(), vec.end());
//for (auto u: vec) cout << u.F << " " << u.S << endl;
for (int i = 1; i < SZ(vec); i++) {
ll st = vec[i-1].F, ft = vec[i].F;
ans[open] += ft - st;
if (vec[i].S) open++;
else open --;
}
ll s = 0;
for (int i = 0; i <= n; i++) {
s += ans[i];
cout << s << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |