CODEFORCES 270C Magical Boxes <<小箱子装大箱子>>
来源:互联网 发布:淘宝兼职红包单 编辑:程序博客网 时间:2024/03/29 21:43
题意:小箱子可以装在大箱子里,给出各种箱子的边长及个数,求把所有箱子装入一个箱子,那么此箱子最小边长是2^i,输出i
样例:
Input
2
0 3
1 5
Output
3
Input
1
0 4
Output
1
Input
2
1 10
2 2
Output
3
#include <iostream>#include <cstdio>#define LL long long#include <cstdlib>#include <map>#define MAXN 200005#include <algorithm>#include <cmath>using namespace std;struct Edge{ long long ki; long long ai; bool operator<(const Edge& ee) { return ki > ee.ki; }}e[100005];int main(){ long n,i; long long index,ans; while(cin>> n) { index = -1; for(i=0; i<n; i++) { cin>>e[i].ki>>e[i].ai; if(index < e[i].ki) index = e[i].ki; } sort(e,e+n); ans = index + 1; //cout << "ans = " << ans <<endl; for(int i=0; i<n; i++) { index = ans - e[i].ki; if(index>30) continue; index = pow(4.0,index); while(e[i].ai>index) { index*=4; ans++; //cout << "index = " << index << endl; } } cout << ans <<endl; } return 0;}
0 0
- CODEFORCES 270C Magical Boxes <<小箱子装大箱子>>
- Codeforces 270c Magical Boxes
- Codeforces 270C Magical Boxes【排序+进制处理】
- Codeforces #165 div2 C. Magical Boxes
- A. Magical Boxes
- codeforces 903C. Boxes Packing
- Codeforce -269 - A. Magical Boxes
- CodeForces 390C Inna and Candy Boxes
- codeforces 390c Inna and Candy Boxes
- codeforces 551 C GukiZ hates Boxes
- codeforces 390C Inna and Candy Boxes
- 【24.67%】【codeforces 551C】 GukiZ hates Boxes
- Codeforces 821 C. Okabe and Boxes
- Codeforces 821C-Okabe and Boxes
- Codeforces 821C Okabe and Boxes 题解
- codeforces 420 div2 C Okabe and Boxes
- Codeforces#420 C. Okabe and Boxes
- 【Codeforces 821C. Okabe and Boxes】
- SparkStreaming之窗口函数
- SparkStreaming之Output Operations
- CODEFORCES 270B Multithreading <<新闻持续更新>>
- SparkStreaming之Accumulators和Broadcast
- sparkStreamming和高级数据源kafka
- CODEFORCES 270C Magical Boxes <<小箱子装大箱子>>
- 7.1 C语言变量的作用域
- 7.2 C语言变量的存储类别
- Add Binary
- 7.3 LED点阵的介绍
- 7.4 LED点阵的图形显示
- iOS Socket介绍及其简单应用
- 7.5 LED点阵的纵向移动
- javascript 更新联动下拉列表框