#include<iostream> (5488)#include<vector> #include<algorithm> (5863)#include<queue> using namespace std; struct time { int start; int end; int num; }; struct cmp{ bool operator()(const time a,const time b){ if (a.start == b.start)return a.num > b.num; return a.start > b.start; } }; int main() { int t; cin >> t; while (t--) { int n; cin >> n; priority_queue<time, vector<time>, cmp> q; for (int i = 0; i < n; i++) { time temp; cin >> temp.start >> temp.end; temp.num = i; q.push(num1[i]); } vector<int> list(n, 0); time temp = q.top(); q.pop(); list[temp.num] = temp.start; int pre = temp.start + 1; for (int i = 1; i < n; i++) { time temp = q.top(); q.pop(); if (pre >= temp.end)continue; list[temp.num] = max(temp.start, pre); pre = max(temp.start, pre) + 1; } for (int i = 0; i < n; i++) { cout << list[i] << " "; } cout << endl; } return 0; } 有没有朋友看看代码存在的问题
点赞 评论

相关推荐

牛客网
牛客企业服务