Re: [閒聊] 每日LeetCode
第一次寫hard
馬的寫了快兩小時
還差點超過time limit
改天再優化好了 寫到快吐血
2402. Meeting Rooms III
class Solution {
public:
static bool cmp1(vector<long long>& a, vector<long long>& b){
if(a[0]==b[0]) return a[2]<b[2];
return a[0]<b[0];
}
static bool cmp2(vector<long long>& a, vector<long long>& b){
if(a[1]==b[1]) return a[2]<b[2];
return a[1]>b[1];
}
static bool cmp3(vector<int>& a, vector<int>& b){
return a[0]<b[0];
}
int mostBooked(int n, vector<vector<int>>& meetings) {
vector<vector<long long>> pq (n, vector<long long>(3,0));
sort(meetings.begin(), meetings.end(), cmp3);
for(int i=0; i<n; i++){
pq[i][2]=i;
}
for(const auto& v:meetings){
for(auto& t:pq){
if(t[0]<=v[0]) t[0]=0;
}
sort(pq.begin(), pq.end(), cmp1);
if(pq[0][0]<v[0]){
pq[0][0]=v[1];
pq[0][1]++;
}
else{
pq[0][1]++;
pq[0][0]+=v[1]-v[0];
}
sort(pq.begin(), pq.end(), cmp1);
}
sort(pq.begin(), pq.end(), cmp2);
return pq[0][2];
}
};
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.230.5.75 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1708235549.A.F29.html
推
02/18 13:56,
1年前
, 1F
02/18 13:56, 1F
→
02/18 13:56,
1年前
, 2F
02/18 13:56, 2F
推
02/18 13:56,
1年前
, 3F
02/18 13:56, 3F
超花時間 肏雞掰
→
02/18 13:56,
1年前
, 4F
02/18 13:56, 4F
他考我domain knowledge 跟晶片設計timiing相關的
還有乒乓要去哪看ㄚ 巴哈沒有
推
02/18 13:57,
1年前
, 5F
02/18 13:57, 5F
※ 編輯: wu10200512 (61.230.5.75 臺灣), 02/18/2024 14:03:22
→
02/18 14:06,
1年前
, 6F
02/18 14:06, 6F
→
02/18 14:08,
1年前
, 7F
02/18 14:08, 7F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 690 之 719 篇):