Ural1876(贪心)
来源:互联网 发布:拓客宝软件怎么收费 编辑:程序博客网 时间:2024/05/18 00:25
题目链接:点击打开链接
解题思路:
按照两个方面来贪:首先第一点,我们可以想到先将所有右脚的鞋子穿完,然后把所有剩余的右脚鞋子丢掉,最后穿够左脚即可。即b * 2 + 40;
第二点,我们先穿39个右脚的鞋子,然后穿40个左脚的鞋子,之后我们把所有剩下的左脚鞋子丢掉,最后再花1s时间穿1个右脚鞋子。即39 * 2 + 40 + 2 * (a - 40) + 1;
二者中取最大值即可。
完整代码:
#include <algorithm>#include <iostream>#include <cstring>#include <climits>#include <cstdio>#include <string>#include <cmath>#include <map>#include <queue>using namespace std;typedef long long LL;const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const double EPS = 1e-9;const double PI = acos(-1.0); //M_PI;int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int a , b; while(cin >> a >> b) { int res = max( b * 2 + 40 , 119 + 2 * (a - 40) ); cout << res << endl; }}
更多精彩请访问:点击打开链接
0 0
- Ural1876(贪心)
- URAL1876
- Ural1876-Centipede's Morning
- 贪心!
- 贪心~
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- 贪心
- C# Winform 按回车键查找下一个可设置焦点的组件
- windos下 redis安装与使用
- 安卓 点击ListView中的Button 需要的xml必须项
- 基于sonarQube的源码测试实践记录 一
- 【ITOO】 EF框架之ORM思想的体现
- Ural1876(贪心)
- MonkeyRunner源码分析之启动
- online_judge_1183
- java文件上传
- 激光焊接规划局非官方
- Onvif开发之Linux下gsoap的使用及移植
- QDir的用法
- C#中的委托和事件
- HDU2544 最短路 Floyd实现