sicily 1134.积木分发
2013-10-24 20:19
417 查看
策略:按小朋友所需积木块数从小到大排序
#include <iostream> #include <algorithm> #include <vector> using namespace std; struct Info { int have; int need; Info(int a,int b) { this->have = a; this->need = b; } Info() {} }; bool com(Info a,Info b) { return a.need < b.need; } int main() { int n,m,i; vector<Info> data; int a,b; while(cin >> n >> m && n != 0) { data.clear(); for(i = 0;i < n;i++) { cin >> a >> b; data.push_back(Info(a,b)); } sort(data.begin(),data.end(),com); int temp = m; for(i = 0;i < n;i++) { if(temp < data[i].need) break; else temp += data[i].have; } if(i < n) cout << "NO" << endl; else cout << "YES" << endl; } return 0; }
相关文章推荐
- Sicily 1134 积木分发
- Sicily1134——积木分发
- Sicily 1134. 积木分发
- Sicily 1134. 积木分发
- Sicily 1134 积木分发
- Sicily 1134 积木分发
- Sicily 1134 积木分发
- [sicily]1134. 积木分发
- sicily 1134 积木分发
- sicily 1134. 积木分发
- sicily--1134 积木分发
- sicily 1134. 积木分发
- Sicily 1134 积木分发
- sicily1134.积木分发
- Sicily 1134. 积木分发
- sicily 1134 积木分发
- Sicily 1134.积木分发
- <OJ_Sicily>1134积木分发
- [sicily][排序]1134. 积木分发
- soj - 1134 - 积木分发