Codeforces Round #523 (Div. 2) D. TV Shows

传送门

https://www.cnblogs.com/violet-acmer/p/10005351.html

题意:

  有n个节目,每个节目都有个开始时间和结束时间。

  定义x,y分别为租电视需要的花费和组完后

原文地址:https://www.cnblogs.com/violet-acmer/p/10050210.html

时间: 2024-11-03 12:52:10

Codeforces Round #523 (Div. 2) D. TV Shows的相关文章

Codeforces Round #524 (Div. 2)D - TV Shows

题意是给你n个节目,每次租一台电视需要消耗x+(r-l)*y元,问你怎么样安排才能使得看完所有节目并且消费最少,输出最少的金额 做法是按节目开始时间l排序,遍历所有节目,如果该节目不能在已有的电视上播放或者在已有的电视上播放消耗比再去借一台更多的时候, 那么就再去借一台电视机,当有多个电视机可以播放的时候,贪心选择r最大的电视机.由于是按l升序排序,当(tv[i].l-r)*y>x的时候则表明此时 用已有的电视机播放不如再去借一台,而剩下的l只会更大,所以要erase当前的电视机,否则会超时.P

Codeforces Round #523 (Div. 2) Solution

A. Coins Water. 1 #include <bits/stdc++.h> 2 using namespace std; 3 int n, s; 4 5 int main() 6 { 7 while (scanf("%d%d", &n, &s) != EOF) 8 { 9 int res = 0; 10 for (int i = n; i >= 1; --i) while (s >= i) 11 { 12 ++res; 13 s -=

Codeforces Round #523 (Div. 2) B. Views Matter

B. Views Matter 题目链接:https://codeforc.es/contest/1061/problem/B 题意: 给一个类似棋盘的东西,对于每一列都放有格子,问在无重力的条件下,最多可以抽取多少个格子,并且使纵向视图和横向视图保持原样. 题解: 这题还是采用贪心的方法,先排个序,这并不影响结果. 对于每一列,肯定有一个棋子来满足纵向视图,然后尽可能地将它往高处放来满足横向视图,前提是高度低于它的横向视图已经有棋子了. 代码如下: #include <bits/stdc++.

Codeforces Round #523 (Div. 2) C. Multiplicity

C. Multiplicity 题目链接:https://codeforc.es/contest/1061/problem/C 题意: 给出一串数,问它的"好序列"有多少.好序列的定义是,首先是一个子序列(顺序可以打乱),其次,序列相应位置的数可以除尽该位置编号. 题解:这题是dp,我没有想到,主要是状态的定义. 定义dp(i,j):在a1,a2...ai中长度为j的好序列的个数,这样dp转移方程就为:if ai%j==0:  dp(i,j)=dp(i-1,j-1)+dp(i-1,j)

Codeforces Round #260 (Div. 1) A. Boredom (DP)

题目链接:http://codeforces.com/problemset/problem/455/A A. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bored, he comes up with

Codeforces Round #118 (Div. 1) A Mushroom Scientists (多元函数极值问题+拉格朗日乘数法)

Codeforces Round #118 (Div. 1) A Mushroom Scientists 题意:提炼出来就是求f(x,y,z)=x^a*y^b*z^b,这个三元函数在(0 思路: 更严格的还要证明在边界所取到的值比极值要小. 注意:%.10lf注意看题目的output AC代码: #include int main(){ int s; ... meilijie.com/ask/view/377116/ meilijie.com/ask/view/377668/ meilijie.

Codeforces Round #298 (Div. 2) A、B、C题

题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (i and i + 1) always studied side

Codeforces Round #286 (Div. 2) B. Mr. Kitayuta&#39;s Colorful Graph +foyd算法的应用

B. Mr. Kitayuta's Colorful Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the g

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i