HDU 4864(Task)
来源:互联网 发布:淘宝刷客究竟犯不犯法 编辑:程序博客网 时间:2024/05/16 12:53
题意:略。
思路:贪心。题目很特别的给出了获得金钱的计算公式为500*x+2*y,y<=100,所以可以按任务时间从大到小排序,
然后每个任务找出大于该任务难度且与难度最接近的机器完成该任务。
#include <set>#include <cstdio>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;const int N = 100005;struct Task { int x, y; bool operator<(const Task &rhs) const { if(x == rhs.x) return y > rhs.y; return x > rhs.x; }} task[N];int main() { int n, m; while(cin >> n >> m) { multiset<int> S[105]; LL ans = 0; int maxLevel = 0, count = 0; for(int i = 0; i < n; i++) { int x, y; scanf("%d%d", &x, &y); S[y].insert(x); maxLevel = max(maxLevel, y); } for(int i = 0; i < m; i++) { scanf("%d%d", &task[i].x, &task[i].y); } sort(task, task + m); for(int i = 0; i < m; i++) { int x = task[i].x; int y = task[i].y; for(int j = y; j <= maxLevel; j++) { if(S[j].empty()) continue; multiset<int>::iterator iter = S[j].lower_bound(x); if(iter == S[j].end() || *iter < x) { continue; } else { count++; ans += 500ll * x + 2ll * y; S[j].erase(iter); break; } } } cout << count << " " << ans << endl; } return 0;}
0 0
- hdu 4864 Task 贪心
- hdu 4864 Task 贪心
- HDU 4864(Task)
- HDU 4864 Task
- HDU 4864 Task(贪心)
- HDU 4864 Task(贪心)
- hdu-4864-Task
- 【HDU 4864】Task【贪心】
- Hdu-4864-Task
- HDU 4864 Task
- HDU 4864 Task 贪心
- HDU 4864 Task 贪心
- hdu 4864 Task
- hdu 4864 Task(贪心)
- HDU 4864 Task (贪心)
- HDU 4864 Task
- HDU 4864----Task
- HDU 4864 Task
- ios8技术调研
- tomcat 6.1.18启动报错IOException while loading persisted sessions: java.io.EOFException
- 09 js继承
- poj 3625 Building Roads(图论:最小生成树)
- gridview使用总结
- HDU 4864(Task)
- starling 学习(二)配置过程
- 从用python做zoj1011发生Non-zero Exit Code错误说起
- 匹配最大字符串
- 10.2.0.1.1 grid control的启动和关闭
- 选择,冒泡排序
- 使用Label控件直接显示并更新时间
- capturing self strongly in this block is likely to lead to a retain cycle
- VIM中的搜索和替换