我的贪心思路是,用最差的机器完成当前他能完成的收益最高的任务。可是WA40%,不知道为什么,感觉很完美。 #include <bits/stdc++.h> #define MEM(a,b) memset(a, b, sizeof(a)) using namespace std; typedef long long LL; typedef pair<int,int> pii; struct Node {     int t, val;     Node() {}     Node(int t, int v) : t(t), val(v) {}     bool operator < (const Node& o) const {         int x1 = 200 * t + 3 * val;         int x2 = 200 * o.t + 3 * o.val;         return x1 < x2;     } }; priority_queue<Node>q; int task[2010][110]; int mach[2010][110]; int main() {     int n, m, x, y;     scanf("%d%d", &n, &m);     for(int i = 0; i < n; ++ i) {         scanf("%d%d", &x, &y);         mach[x][y]++;     }     for(int i = 0; i < m; ++ i) {         scanf("%d%d", &x, &y);         task[x][y]++;     }     LL sum_task = 0, sum_val = 0;     for(int i = 1; i < 1440; ++ i) {         for(int j = 0; j <= 100; ++ j) {             while(task[i][j]--) {                 q.push(Node(i, j));             }             while(mach[i][j]--) {                 if(!q.empty()) {                     Node top = q.top();                     q.pop();                     sum_task++;                     sum_val += 1LL * 200 * top.t + 1LL * 3 * top.val;                 }             }         }     }     cout << sum_task << ' ' <<sum_val << endl;     return 0; }
点赞 2

相关推荐

点赞 评论 收藏
转发
牛客网
牛客企业服务