全部评论
第一题一开始图方便,用个sort排序不出来,然后用priority_queue还是出不来,阿里的题看起来思路不难,每次写出0来,求朋友们解答。
第一题我也0了,最后的时候想了一下是不是可能是因为判题数据的到达时间不是升序?
阿里卡笔试吗,佬们
第一题0%,原因竟然是输出不是按照学生序号输出的,而是按照学生排队的顺序😓
#include<iostream> #include<vector> #include<algorithm> #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; } 有没有朋友看看代码存在的问题
第一题过的老哥,发份pasteubuntu的代码链接吧
优先队列保存序号,然后模拟也是0
第二题超时,只会用笨方法每次直接交换,哪个大佬能告知下思路ww,或者贴个java的解法,谢谢了
大佬们第一题就是0,求个题解,我很纳闷
相关推荐
在度假的布拉德很想退...:敢主动删hr微信你也是强
点赞 评论 收藏
分享
06-09 11:12
重庆移通学院 运营 不要停下啊:大二打开牛客,你有机会开卷了,卷起来
,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会
,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享
06-24 00:02
北京电子科技职业学院 活动运营 点赞 评论 收藏
分享