Codeforces 629D
2017-04-11 23:23
246 查看
树状数组
题目链接: http://codeforces.com/problemset/problem/629/D代码如下:
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const int N = 1e5+10; const double PI = acos(-1.0); typedef long long ll; ll a , b , tree ; void update(int k, ll c, int n) { while(k <= n) { tree[k] = max(tree[k], c); k += k&(-k); } return ; } ll query(int k) { ll ans = 0; while(k) { ans = max(tree[k], ans); k -= k&(-k); } return ans; } int main() { int n; cin >> n; ll r, h; for(int i = 1;i <= n;i++) cin >> r >> h, b[i] = a[i] = r*r*h; sort(b+1, b+1+n); ll ans = 0; for(int i = 1;i <= n;i++) { int pos = lower_bound(b+1, b+1+n, a[i]) - b; ll tmp = query(pos-1) + a[i]; ans = max(ans, tmp); update(pos, tmp, n); } printf("%.10f\n", PI*ans); return 0; }
相关文章推荐
- Codeforces 512B Fox And Jumping dp+gcd
- codeforces 589d(相遇问题)
- Codeforces 839B Game of the Rows 贪心
- codeforces 509F Progress Monitoring (区间dp)
- 【动态规划】Codeforces 706C Hard problem
- CodeForces - 11D 【状压DP+无向图找环】
- codeforces 478D Red-Green Towers (dp)
- CodeForces 705B (训练水题)
- CodeForces - 785D(92/600)
- Codeforces-507-C(c++)
- CodeForces 327C
- Codeforces 839B Game of the Rows - 贪心
- codeforces 510D Fox And Jumping
- CodeForces 510C (拓扑排序)
- CodeForces - 404D 【计数DP】
- codeforces 494A Treasure
- codeforces 492E. Vanya and Field(exgcd求逆元)
- Codeforces 18D
- codeforces 148E Porcelain (dp)
- Codeforces-----510B Fox And Two Dots 搜索