codeforces 230A
来源:互联网 发布:拉普拉斯变换公式矩阵 编辑:程序博客网 时间:2024/05/01 20:20
简单的贪心算法。。。
按Dragon的strength排序。。。
#include <algorithm> #include <iostream> using namespace std; struct cmp { int x, y;}array[1005]; bool tmp ( cmp a, cmp b ) { return a.x < b.x;} int main ( ) { int s, n, x, y, ans; ans = 0; cin >> s >> n; for ( int i = 0; i < n; ++i ) cin >> array[i].x >> array[i].y; sort ( array, array + n, tmp ); for ( int i = 0; i < n; ++i ) { if ( s > array[i].x ) { s += array[i].y; ans++; } } if ( ans == n ) cout << "YES" << endl; else cout << "NO" << endl;}
- codeforces 230A
- codeforces 230/A 水~~
- CodeForces 230A Dragons
- Codeforces 230A Dragons
- CodeForces 230 A. Dragons
- codeforces div2 round#230 A
- CodeForces 230A Dragons(贪心)
- CodeForces 230A 贪心+排序
- CodeForces-a
- Codeforces 903A A
- codeforces-230A-Dragons(贪心+排序)
- Codeforces Round #230 (Div. 2) A. Nineteen
- Codeforces Round #230 (Div. 2)A. Nineteen
- CodeForces 18A A - Triangle
- CodeForces 133A A. HQ9+
- codeforces 651A A. Joysticks
- 【Codeforces 597A】A. Divisibility
- 【 Codeforces 615A】A. Bulbs
- warning C4018: “<”: 有符号/无符号不匹配
- 递归实现TreeView绑定表MenuTree
- Python网页抓取、模拟登录
- 2012年的最后一天
- 实习感想之第一阶段
- codeforces 230A
- 如何编写Linux设备驱动程序
- 写在2012年的尾巴上
- 元旦快乐的二维码——明天就是2013了,快向朋友来个二维码的新潮趣味问候!
- 清空标签间的内容(innerHTML)和 value
- TerminateThread的缺点
- Unity3D For iPhone游戏引擎之构建3D游戏的基本地形(四)
- poj 1012 -- Joseph (约瑟夫环)
- MYSQL基本命令的使用