Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <vector>
- #include <cmath>
- #include <map>
- #include <algorithm>
- #include <string>
- #include <utility>
- #include <set>
- #include <stack>
- #include <deque>
- #include <ctime>
- #include <random>
- #include <cassert>
- #include <cmath>
- #include <climits>
- #include <queue>
- #include <cstring>
- #include <iomanip>
- //#pragma GCC optimize ("O3")
- #define int long long
- #define fi(a,b) for (int i=a;i<b;i++)
- #define fj(a,b) for (int j=a;j<b;j++)
- #define fk(a,b) for (int k=a;k<b;k++)
- #define fi1(a,b) for (int i=a-1;i>=b;i--)
- #define fj1(a,b) for (int j=a-1;j>=b;j--)
- #define fx(x,a) for (auto& x : a)
- #define lb lower_bound
- #define ub upper_bound
- #define sz(x) (int)x.size()
- #define all(x) begin(x), end(x)
- #define rall(x) rbegin(x), rend(x)
- using namespace std;
- typedef long long ll;
- typedef char ch;
- typedef string str;
- typedef vector <long long> vl;
- typedef vector <int> vi;
- typedef vector<vector<long long>> vvl;
- typedef vector<vector<int>> vvi;
- typedef vector<pair<ll, ll>> vpll;
- typedef vector<pair<int, int>> vpii;
- typedef vector<vector<pair<ll, ll>>> vvpll;
- typedef vector<vector<pair<int, int>>> vvpii;
- typedef vector<char> vch;
- typedef vector<vector<char>> vvch;
- typedef vector<string> vs;
- typedef map<ll, ll> mll;
- typedef map<int, int> mii;
- typedef map<ll, ch> mlch;
- typedef map<int, ch> mich;
- typedef map<ch, int> mchi;
- typedef map<ch, ll> mchl;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef unsigned long long ull;
- ll powmod(ll a, ll b, ll mod) {
- if (b == 0 || a == 1)
- return mod == 1 ? 0 : 1;
- if (b % 2 == 0) {
- ll k = powmod(a, b / 2, mod);
- return (k * k) % mod;
- }
- else {
- ll k = powmod(a, b / 2, mod);
- return ((k * k) % mod * a) % mod;
- }
- }
- ll gcd(ll a, ll b) {
- while (b) {
- a %= b;
- swap(a, b);
- }
- return a;
- }
- bool is_prime(ll n) {
- ll bound = sqrt(n);
- ll d = 2;
- while (d <= bound && n % d != 0)
- ++d;
- return d * d > n;
- }
- const int MOD = 1000000007;
- const int INF = 1000000050;
- const int MX = 100010;
- const double EPS = 1e-9;
- mt19937 rnd;
- struct inf {
- int l;
- int r;
- int f;
- };
- signed main() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- const int MAXN = 10000;
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n, v, F;
- cin >> n >> v >> F;
- cout.precision(10);
- ll sum = 0;
- ll allt = 0;
- fi(0, n) {
- int t, k;
- cin >> t >> k;
- fj(0, k) {
- int l;
- int r;
- int f;
- cin >> l >> r >> f;
- if (sum + (r - l) * f > F) {
- double left = l;
- double right = r;
- while (right - left > EPS) {
- double m = (right + left) / 2;
- if (sum + (m - l) * f >= F)
- right = m;
- else
- left = m;
- }
- cout <<double(allt) + left;
- } else if (sum + (r - l) * f == F) {
- cout << allt + r;
- }
- sum += (r - l) * f;
- }
- allt += t;
- }
- cout << -1;
- // you should actually read the stuff at the bottom
- }
- /* stuff you should look for
- * int overflow, array bounds
- * special cases (n=1?), set tle
- * do smth instead of nothing and stay organized
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement