惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
P
Palo Alto Networks Blog
SecWiki News
SecWiki News
S
Secure Thoughts
P
Privacy International News Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tenable Blog
W
WeLiveSecurity
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
Cyberwarzone
Cyberwarzone
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
L
Lohrmann on Cybersecurity
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Scott Helme
Scott Helme
H
Hacker News: Front Page
博客园 - Franky
月光博客
月光博客
D
DataBreaches.Net
Know Your Adversary
Know Your Adversary
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
O
OpenAI News
N
Netflix TechBlog - Medium
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
博客园 - 叶小钗
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
B
Blog
人人都是产品经理
人人都是产品经理
I
Intezer
酷 壳 – CoolShell
酷 壳 – CoolShell
云风的 BLOG
云风的 BLOG
IT之家
IT之家
V
Vulnerabilities – Threatpost
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
Google Online Security Blog
Google Online Security Blog
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
雷峰网
雷峰网

博客园 - 北叶青藤

2096. Step-By-Step Directions From a Binary Tree Node to Another Find path from root to a target node in Binary Tree When Dijkstra Algorithm Should be Use? 1188. Design Bounded Blocking Queue 1115. Print FooBar Alternately 1114. Print in Order 1242. Web Crawler Multithreaded Python Multi-threading bot ip Log Rate Limiter Same Word of HTML Labels Most Frequent Call Chain remove prefix in a words list 1102. Path With Maximum Minimum Value Property Booking Optimizer minimum number 755. Pour Water Keyword Tagging in Reviews with Overlapping Matches Retryer Function Implementation 1125. Smallest Sufficient Team Print the terrain Split stay 滑雪问题 845. Longest Mountain in Array 723. Candy Crush 1539. Kth Missing Positive Number 1650. Lowest Common Ancestor of a Binary Tree III 424. Longest Repeating Character Replacement 843. Guess the Word 551. Student Attendance Record I
Task scheduling problem
北叶青藤 · 2026-02-22 · via 博客园 - 北叶青藤

Maximize task profits by their ddl.  input: [(taskName, ddl, profit)], output: ([taskOrder], maxProfit)

每个task只需要花一天时间,一天只可以做一个task

 1 def maximize_task_profits(tasks):
 2     if not tasks:
 3         return [], 0
 4 
 5     tasks.sort(key=lambda x: x[2], reverse=True)
 6     max_deadline = max(task[1] for task in tasks)
 7     # 时间槽,从 1 开始
 8     slots = [None] * (max_deadline + 1)
 9 
10     total_profit = 0
11 
12     for name, ddl, profit in tasks:
13         for day in range(ddl, 0, -1):
14             if slots[day] is None:
15                 slots[day] = name
16                 total_profit += profit
17                 break
18 
19     task_order = [task for task in slots[1:] if task is not None]
20 
21     return task_order, total_profit