UVALive 6530 Football (水
2014-10-30 13:18
281 查看
题目链接:点击打开链
#include <cstdio> #include <vector> #include <algorithm> using namespace std; typedef long long ll; vector<int> s; int main() { int n, k; while (~scanf("%d%d", &n, &k)) { s.clear(); int sum = 0, cnt = 0; for(int i = 0, x, y; i < n; i ++) { scanf("%d%d", &x, &y); if(x > y) sum += 3; else if(x == y) { cnt ++; sum ++; } else s.push_back(y-x); } if(k >= cnt) { sum += 2*cnt; k -= cnt; } else { sum += 2*k; k = 0; } sort(s.begin(), s.end()); for(int i = 0; i < s.size() && k > 0; i ++) { if(k > s[i]) { sum += 3; k -= s[i]+1; } else if(k == s[i]) { sum += 1; k -= s[i]; } } printf("%d\n", sum); } return 0; }
相关文章推荐
- 【瞎搞】 UVALive 6530 Football
- 【瞎搞】 UVALive 6530 Football
- UVALive 6530 Football (水
- 【贪心】UVALive 6530——Football
- UVALive-7601 Football(思维)
- UVALive 6485 Electric Car Rally (BFS,PQ)
- UVALive 3635 分派
- UVALive 2963 Hypertransmission
- UVALive 7509 三分
- UVALive - 7501 思维 +二分
- UVALive 3266 Tian Ji -- The Horse Racing
- UVALive - 4254 Processor 二分+优先队列
- UVAlive4097 Yungom(思路)
- uva 10716 - Evil Straw Warts Live
- 伸展树模板(BZOJ 1500,UVALive 3961 HDU 1890)
- Jamie's Contact Groups UVALive - 3268
- UVALive6257-剪枝|dp-Chemist's vows
- UVaLive 6038 - Grandpa's Walk 解题报告
- UVALive 2689 极大子正方形
- UVALive - 7503 Change(规律)