标签:online space com arc div ble tar foo http
题目链接:点击打开链
#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; }
标签:online space com arc div ble tar foo http
原文地址:http://www.cnblogs.com/tlnshuju/p/6891631.html