Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*just read the problem and analyze the answer.....
- As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.
- Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylinder. Babaei has n simple cakes and he is going to make a special cake placing some cylinders on each other.
- However, there are some additional culinary restrictions. The cakes are numbered in such a way that the cake number i can be placed only on the table or on some cake number j where jā<āi. Moreover, in order to impress friends Babaei will put the cake i on top of the cake j only if the volume of the cake i is strictly greater than the volume of the cake j.
- Babaei wants to prepare a birthday cake that has a maximum possible total volume. Help him find this value.
- */
- ///#include <stdio.h>
- ///#include <iostream>
- ///#include <cstring>
- ///#include <cmath>
- ///#include <algorithm>
- ///#include <string>
- ///#include <vector>
- ///#include <map>
- ///#include <set>
- ///#include <queue>
- ///#include <cstdlib>
- ///#include <limits>
- ///#include <iostream>
- ///#include <sstream>
- ///#include <unordered_set>
- ///#include <unordered_map>
- ///#include <random>
- #include <bits/stdc++.h>
- ///#include <bits/stdtr1c++.h>
- ///#include <ext/pb_ds/assoc_container.hpp>
- ///#include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- ///using namespace __gnu_pbds;
- #define MAX 200005
- #define EPS 1e-9
- #define ull unsigned long long
- #define ll long long
- #define inf INT_MAX
- #define pi acos(-1.0)
- #define vi vector<int>
- #define vl vector<long long>
- #define pii pair<int,int>
- #define pll pair<long long,long long>
- #define mp make_pair
- #define mem(a, v) memset(a, v, sizeof (a))
- #define mod 1000000007
- #define all(a) a.begin(),a.end()
- #define rall(a) a.rbegin(),a.rend()
- #define ff first
- #define ss second
- #define arsort(ar,n) sort(ar,ar+n);
- #define vsort(v) sort(v.begin(),v.end())
- #define vrev(v) reverse(v.begin(),v.end())
- #define arrev(ar,n) reverse(ar,ar+n)
- #define pb push_back
- #define popb pop_back
- #define booster() ios_base::sync_with_stdio(0); cin.tie(0);
- #define read(f) freopen(f, "r", stdin)
- #define scani(x) scanf("%d",&x)
- #define scanl(x) scanf("%I64d",&x)
- #define scand(x) scanf("%lf",&x)
- #define scans(x) scanf("%s",x)
- #define OUT(x) printf("%d\n",x)
- #define OUTS(x) printf("%d ",x)
- #define min3(a,b,c) min(a,min(b,c))
- #define max3(a,b,c) max(a,max(b,c))
- #define min4(a,b,c,d) min(min(a,b),min(c,d))
- #define max4(a,b,c,d) max(max(a,b),max(c,d))
- #define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
- #define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
- #define bitCheck(a,k) ((bool)(a&(1<<(k))))
- #define bitOff(a,k) (a&(~(1<<(k))))
- #define bitOn(a,k) (a|(1<<(k)))
- #define bitFlip(a,k) (a^(1<<(k)))
- #define POPCOUNT __builtin_popcount
- #define POPCOUNTLL __builtin_popcountll
- #define RIGHTMOST __builtin_ctzll
- #define LEFTMOST(x) (63-__builtin_clzll((x)))
- #define scani2(a,b) scani(a) , scani(b)
- #define scani3(a,b,c) scani(a), scani(b), scani(c)
- #define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
- #define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
- #define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- /*********************Ordered Multiset*************************/
- /*** Needs C++11 or C++14 ***/
- /// Treap supporting duplicating values in set
- /// Maximum value of treap * ADD must fit in long long
- /*
- struct Treap{ /// hash = 96814
- int len;
- const int ADD = 1000010;
- const int MAXVAL = 1000000010;
- tr1::unordered_map <long long, int> mp; /// Change to int if only int in treap
- tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> T;
- Treap(){
- len = 0;
- T.clear(), mp.clear();
- }
- inline void clear(){
- len = 0;
- T.clear(), mp.clear();
- }
- inline void insert(long long x){
- len++, x += MAXVAL;
- int c = mp[x]++;
- T.insert((x * ADD) + c);
- }
- inline void erase(long long x){
- x += MAXVAL;
- int c = mp[x];
- if (c){
- c--, mp[x]--, len--;
- T.erase((x * ADD) + c);
- }
- }
- /// 1-based index, returns the K'th element in the treap, -1 if none exists
- inline long long kth(int k){
- if (k < 1 || k > len) return -1;
- auto it = T.find_by_order(--k);
- return ((*it) / ADD) - MAXVAL;
- }
- /// Count of value < x in treap
- inline int count(long long x){
- x += MAXVAL;
- int c = mp[--x];
- return (T.order_of_key((x * ADD) + c));
- }
- /// Number of elements in treap
- inline int size(){
- return len;
- }
- };
- typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;///*X.find_by_order();X.order_of_key();
- template <class T> inline bool isLeap(T y) {return (y % 400 == 0) || (y % 100 ? y % 4 == 0 : false); }*/
- template< class T > inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); }
- template< class T > inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) * (b)); }
- template <class T> inline T BigMod(T Base,T power,T M=mod){if(power==0)return 1;if(power&1)return ((Base%M)*(BigMod(Base,power-1,M)%M))%M;else{T y=BigMod(Base,power/2,M)%M;return (y*y)%M;}}
- template <class T> inline T ModInv (T A,T M = mod){return BigMod(A,M-2,M);}
- int fx[] = {-1,+0,+1,+0,+1,+1,-1,-1,+0};
- int fy[] = {+0,-1,+0,+1,+1,-1,+1,-1,+0};
- int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- /*********************** let the play begin() ***********************************/
- int n;ll r[MAX],h[MAX],pum[MAX],I[MAX];
- vector<pll>v;
- ll tree[4*MAX];
- void update(int node,int b,int e,int indx,ll val)
- {
- if(b>indx||indx>e)return ;
- if(b==e)
- {
- tree[node] = val;
- return ;
- }
- int mid = (b+e)>>1;
- int left = 2*node;
- int right = left+1;
- update(left,b,mid,indx,val);
- update(right,mid+1,e,indx,val);
- tree[node] = max(tree[left] , tree[right]);
- }
- ll query(int node,int b,int e,int l,int r)
- {
- if(b>r||l>e||b>e)return 0;
- if(b>=l&&e<=r)
- {
- return tree[node];
- }
- int mid = (b+e)>>1;
- int left = 2*node;
- int right = left+1;
- ll p1 = query(left,b,mid,l,r);
- ll p2 = query(right,mid+1,e,l,r);
- return max(p1 , p2);
- }
- bool cmp(const pll &a,const pll &b)
- {
- if(a.ff==b.ff)return a.ss>b.ss;
- return a.ff<b.ff;
- }
- ll sum[MAX],mx;
- int main()
- {
- booster()
- ///read("input.txt");
- cin>>n;
- for(int i = 0;i<n;i++)
- {
- cin>>r[i]>>h[i];
- v.pb(pll(r[i]*r[i]*h[i],i+1));
- }
- sort(all(v),cmp);
- v.pb(pll(0,0));
- for(int i = n;i>=1;i--)v[i] = v[i-1];
- ///for(int i = 1;i<=n;i++)cout<<v[i].ff<<" "<<v[i].ss<<endl;
- for(int i = 1;i<=n;i++)
- {
- ll x = query(1,1,n,1,v[i].ss) + v[i].ff;
- mx = max(mx,x);
- update(1,1,n,v[i].ss,x);
- }
- double ans = pi * 1.0 * mx;
- cout<<setprecision(10)<<fixed<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement