Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <memory.h>
- #include <map>
- #include <math.h>
- #include <queue>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <memory.h>
- #include <map>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <complex>
- #include <list>
- #include <deque>
- #pragma comment(linker, "/STACK:16777216") // SET_STACKSIZE_16MB
- using namespace std;
- #ifdef WIN32
- #define LLD "%I64d"
- #else
- #define LLD "%lld"
- #endif
- typedef long long ll;
- typedef unsigned long long ull;
- const long double PI = acos(-1.0);
- const double eps = 1e-12;
- const int INF = 2147483647;
- const ll LLINF = 9223372036854775807LL;
- const int MAXPRIMES = 3163; // 3163 = sqrt(10^9) (FOR GENPRIMES)
- const int MAXSIZESTR = 110; // FOR GEN_HASH
- const int BASE = 31;
- const ll MOD = 1000000073;
- const ll MAXN = 100010;
- #define mp make_pair
- #define pb push_back
- #define sz(x) (int)x.size()
- #define X first
- #define Y second
- #define all(x) x.begin(),x.end()
- struct lenStruct {
- ll left,right;
- ll cnt, color;
- double resColor;
- lenStruct(int left1, int right1, int cnt1, int color1, double resColor1) : left(left1), right(right1), cnt(cnt1), color(color1), resColor(resColor1) {}
- lenStruct() : left(LLINF), right(-1), cnt(0), color(0), resColor(0.) {}
- };
- int n;
- vector<lenStruct> piece;
- bool can[100010] = {false};
- int main()
- {
- freopen("painting.in", "rt", stdin);
- freopen("painting.out", "wt", stdout);
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- scanf("%d", &n);
- for (int i = 0; i < n; i++) {
- ll l,r,c;
- scanf(LLD LLD LLD, &l,&r,&c);
- int kk = 0;
- double maxVal = 0;
- lenStruct newPiece (lenStruct(l,r,1,c,c+0.));
- bool flag = false;
- for (vector<lenStruct>::iterator j = piece.begin(); j != piece.end(); j++, kk++) {
- if (!can[kk]) {
- if (l < (*j).left && r > (*j).left) {
- can[kk] = true;
- newPiece.right = max(newPiece.right, (*j).right);
- newPiece.left = min(newPiece.left, (*j).left);
- newPiece.color += (*j).color;
- newPiece.cnt += (*j).cnt;
- flag = true;
- continue;
- }
- else {
- if (r > (*j).right && l < (*j).right) {
- can[kk] = true;
- newPiece.right = max(newPiece.right, (*j).right);
- newPiece.left = min(newPiece.left, (*j).left);
- newPiece.color += (*j).color;
- newPiece.cnt += (*j).cnt;
- flag = true;
- continue;
- }
- else {
- if (l >= (*j).left && r <= (*j).right) {
- can[kk] = true;
- newPiece.right = max(newPiece.right, (*j).right);
- newPiece.left = min(newPiece.left, (*j).left);
- newPiece.color += (*j).color;
- newPiece.cnt += (*j).cnt;
- flag = true;
- continue;
- }
- }
- }
- maxVal = max(maxVal, (*j).resColor);
- }
- }
- if (flag) newPiece.resColor = (newPiece.color+0.) / newPiece.cnt;
- maxVal = max(maxVal, newPiece.resColor);
- piece.pb(newPiece);
- printf("%.6f\n", maxVal);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment