CF767 B. The Queue 贪心+细节】的更多相关文章

LINK 题意:一个业务开始时间为s,结束时间为f,一个人办护照的时间需要m分(如果在x时开始服务,且x+m==f那么还是合法的),你可以选择任意时间到达,但如果你和其他人同时到达,你要排在他的后面.问什么时候去等待时间最小. 思路:贪心,对所有人枚举在他之前1分钟到达和同时到达的情况. 因为对于任意一个人,在他1分前到达时,能够保证必定先于该人服务,且等待前一个人服务时间最小,而同时到达时能保证必定比后面的人先服务. 不断更新开始的时间为前一个人结束服务时间,并更新最小等待时间. 要注意特殊情…
题目链接:http://codeforces.com/problemset/problem/545/D 题解: 问经过调整,最多能使多少个人满意. 首先是排序,然后策略是:如果这个人对等待时间满意,则将其加入队伍中,更新当前的等候时间:如果不满意,既然等待时间最小了都不满意,那把他扔到最后,即跳过他,接着考虑下一个. 代码如下: #include<cstdio>//F - F CodeForces - 545D #include<cstring> #include<cstdl…
Code: #include <bits/stdc++.h> #define setIO(s) freopen(s".in", "r", stdin) #define maxn 4000000 using namespace std; int n, m, tot; int arr[maxn], height[maxn], A[maxn]; namespace SA { int rk[maxn], tp[maxn], sa[maxn], tax[maxn]…
原文地址:http://www.cnblogs.com/GXZlegend/p/6825296.html 题目描述 某公司估计市场在第i个月对某产品的需求量为Ui,已知在第i月该产品的订货单价为di,上个月月底未销完的单位产品要付存贮费用m,假定第一月月初的库存量为零,第n月月底的库存量也为零,问如何安排这n个月订购计划,才能使成本最低?每月月初订购,订购后产品立即到货,进库并供应市场,于当月被售掉则不必付存贮费.假设仓库容量为S. 输入 第1行:n, m, S (0<=n<=50, 0<…
D. Ability To Convert time limit per test 1 second Cmemory limit per test 256 megabytes input standard input output standard output Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English le…
题目描述 Every morning, Farmer John's N (1 <= N <= 25,000) cows all line up for milking. In an effort to streamline the milking process, FJ has designed a two-stage milking process where the line of cows progresses through two barns in sequence, with mi…
A. Snacktower time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
题目: 题意:给你n个数值,要求排列这个序列使得第k个数值的前K-1个数的和>=第k个数值的个数尽可能多: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <stack> #incl…
Tian Ji -- The Horse Racing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37436    Accepted Submission(s): 11248 Problem Description Here is a famous story in Chinese history. "That was about…