Codeforces 825 C Multi-judge Solving
来源:互联网 发布:笔记本温度监控软件 编辑:程序博客网 时间:2024/05/16 10:05
题目地址:http://codeforces.com/contest/825/problem/C
题意:告诉你一个初始值k,一定要满足k>=ai才能写第i题,然后k=max(k,a[i]);判断法官要借几道题才能把他的全部题目解决。
思路:把数组a排序,从后面开始遍历,如果遇见了a[i]/2 > k,就借一道题,把k的值翻倍(PS:这题是严格要是2倍,所以要用a[i] > k * 2,我就在这里wa了两次)
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define LL long long #define N 1010#define M 50010#define inf 0x3f3f3f3f3f3f3f3fusing namespace std;const LL mod = 1e9 + 7;const double eps = 1e-9;LL num[N];bool cmp(LL a, LL b) { return a < b;}int main() { cin.sync_with_stdio(false); LL n, m; LL ans; while (cin >> n >> m) { for (int i = 0; i < n; i++) { cin >> num[i]; } ans = 0; sort(num, num + n, cmp); for (int i = 0; i < n; i++) { while (num[i] > m * 2) { ans++; m *= 2; } m = max(num[i], m); } cout << ans << endl; } return 0;}
阅读全文
0 0
- Codeforces 825 C Multi-judge Solving
- codeforces 825C (Multi-judge Solving)
- 【Codeforces 825 C. Multi-judge Solving】
- Codeforces 825C Multi-judge Solving【水题】
- Educational Codeforces Round 25 C Multi-judge Solving 贪心
- Educational Codeforces Round 25 C. Multi-judge Solving
- Educational Codeforces Round 25 C. Multi-judge Solving
- cf Educational Codeforces Round 25 C. Multi-judge Solving
- CodeForces 825A Multi-judge Solving(阅读题)
- C. Multi-judge Solving 贪心+模拟
- codeforces825C-Multi-judge Solving
- codeforces 822 B Crossword solving
- CodeForces 822B Crossword solving
- Codeforces 822B Crossword solving
- codeforces 822B(Crossword solving) Java
- Codeforces Round #422 B. Crossword solving
- codeforces 822-B. Crossword solving(vector)
- solving
- mysql之运算符和函数
- 0-引言:Morris蠕虫现在还有用吗
- 1-编写一个端口扫描器
- 机器学习资源传送门
- Getting started with TensorFlow on iOS
- Codeforces 825 C Multi-judge Solving
- PHP之十六个魔术方法详细介绍
- MSComm控件详细说明
- 【C++】深拷贝、浅拷贝和写时拷贝
- python一道关于map()的题
- Android 拍照视频音频
- fill
- 啦啦啦啦
- input校验数字且自动跳转下一个input框输入,监听backspace事件