3507 Keep the Customer Satisfied
題意:收到n個訂單,每個訂單有q,d分別代表做這個的時間,和最晚的完成時間,問你最多能接受幾個訂單
思路:貪心,我們顯然要按最早的完成時間排序,那麼接下來,我們用(6,8)和(4,9)做為例子,按照我們的貪心原則我們首先選擇(6,8),然後再(4,9),但顯然(4,9)作為首選才是最好的選擇,試想一下不能兩個都選的情況,就是我們總共做的時間4+6>9(第二個的最遲的時間),那麼我們要刪除做的時間最長的才是最優的
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; const int MAXN = 1000002; struct node{ int q,d; }arr[MAXN]; int n; bool cmp(node a,node b){ return a.d < b.d; } int main(){ int t; scanf("%d",&t); for (int cas = 0; cas < t; cas++){ if (cas) printf("\n"); scanf("%d",&n); for (int i = 0; i < n; i++) scanf("%d%d",&arr[i].q,&arr[i].d); sort(arr,arr+n,cmp); priority_queue<int> Q; int ans = 0; for (int i = 0; i < n; i++){ ans += arr[i].q; Q.push(arr[i].q); while (ans > arr[i].d){ ans -= Q.top(); Q.pop(); } } printf("%d\n",Q.size()); } return 0; }
相關推薦
3507 Keep the Customer Satisfied
題意:收到n個訂單,每個訂單有q,d分別代表做這個的時間,和最晚的完成時間,問你最多能接受幾個訂單 思路:貪心,我們顯然要按最早的完成時間排序,那麼接下來,我們用(6,8)和(4,9)做為例子,按照我們的貪心原則我們首先選擇(6,8),然後再(4,9),但顯然(4,9)作為
Uva 1153 Keep the Customer Satisfied (貪心+優先隊列)
最長 題意 code log algo cmp cst name node 題意:已知有n個工作,已知每個工作需要的工作時間qi和截至時間di,工作只能串行完成,問最多能完成多少個工作 思路:首先我們按照截至時間從小到大排序,讓它們依次進入優先隊列中,當發生執行完成時間大於
uva1153 Keep the Customer Satisfied
日期 const bool pan scan 如果 opera name can 貪心加優先隊列 (默認是小的在前,正好) //這裏又很套路,設隊列裏的都是符合條件的考慮新加入的即可。再處理一下空隊列的情況。很完美// 截止時間短的在前面,幹的就多先根據截止日期排序優先隊列
【POJ】2786-Keep the Customer Satisfied(貪心 + 優先佇列,姿勢不對就要跪)
按照截止日期排序,之後一個一個遍歷,記錄當前時間,如果當前時間大於截止時間,那麼從選過的任務裡刪除一個花費最大的任務 優先佇列維護 14038525 2786 Accepted 11168K 1016MS C++ 905B 2015-04-02 12:22:16 #inc
1153 Keep the Customer Satisfied 顧客是上帝(優先佇列貪心)
大體題意: 給你n (n <= 80w)個工作,告訴你每個工作的持續時間和終止日期,問最多能完成多少個工作? 思路: 其實思路,在PDF中已經很明顯了,先按照終止日期排序,因為要想完成更多的任務,你就必須先完成終止日期小的任務。 其次就是選任務了,在PDF文章中,他選
3 Ways to Enhance the Customer Experience Using AI and Machine Learning
Digital transformation is atop the list of every marketing leader's initiatives. While there's a lot of hype around AI and machine learning, there seems to
The Customer Service Blog By Help Scout
Outside of scheduled team meetings and 1-on-1’s, I’ll often find myself involved in impromptu pairing sessions with a developer (prompted by ?in Slack) whe
Startup CEOs on how to keep the artificial intelligence ball rolling in Canada
The next time you pull out your smartphone and ask Siri or Google for advice, or chat with a bot online, take pride in knowing that some of the theoretical
代寫Java小程序: Finding customer clusters at the Telco
port AR rip ould sco gre 編程 href 領域 There can be no extensions to this date. All assignments for this subject for this semester MUST be s
586. Customer Placing the Largest Number of Orders
https://leetcode.com/articles/customer-placing-the-largest-number-of-orders/ --It can handle the case where more than one customer can have maximum number
L181 The microscopic structure of a cat’s tongue helps keep its fur clean
T.S. eliot's mystery cat, Macavity, besides being a criminal mastermind able to evade the combined ranks of British law enforcement, had a coat that was “d
Android7.0異常:You can not keep you settings in the secure settings.(framework修改)
異常:You can not keep you settings in the secure settings.解決辦法(framework修改) 前言 Android7.0版本,對許可權的管理更加的嚴格,許多Android6.0banb版本上的app都需要對7.0進
Open data, customer experience AI the focus for retail automation
While it might be tempting to dismiss Microsoft's AI technology hype as slick marketing to drum up sales revenue, a number of the company's customers said
Don’t miss the chance to deploy AI in your customer service applications
Customer service is one of the most exposed parts of an organization’s corporate image. Delivering a great customer experi
AI, Chatbots and Designing the Next Generation of Automated Customer Engagement
No matter how much sweetness or spin you add to it, early incarnations of AI-powered chatbots are the call centers of this generation. They're relatively i
How to use AI in the insurance value chain: customer service and policy administration
How do you approach customer service and policy administration within your organization? In this blog post, I'll demonstrate how artificial intelligence (A
Utilising machine learning, AI and the cloud to deliver a more personalised customer experience
Paul Armstrong, Principal Solutions Architect, Amazon Web Services: "To deliver a truly personalised travel experience, the first thing airports and airlin
The Torture of Customer Experience Journey Mapping
The second shortcoming was worse, and more pernicious. The consultant had cooked up “enhancements” to the methodology, that were embedded on the Mapping te
Movement rises to keep humans, not robots, in the driver's seat
Hagerty, the largest insurer of classic cars, wants to save driving as more automakers push to bring self-driving cars to the roads in the future. McKeel H
Solving the Kaggle Telco Customer Churn challenge in minutes with AuDaS
Solving the Kaggle Telco Customer Churn challenge in minutes using AuDaSAuDaS is the automated Data Scientist developed by Mind Foundry which aims to allow