博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力,B.优先队列,C.dp乱搞)...
阅读量:5775 次
发布时间:2019-06-18

本文共 10391 字,大约阅读时间需要 34 分钟。

A. Carrot Cakes

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.

Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.

Input

The only line contains four integers n, t, k, d (1 ≤ n, t, k, d ≤ 1 000) — the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven.

Output

If it is reasonable to build the second oven, print "YES". Otherwise print "NO".

Examples
Input
8 6 4 5
Output
YES
Input
8 6 4 6
Output
NO
Input
10 3 11 4
Output
NO
Input
4 2 1 4
Output
YES
Note

In the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven.

In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.

In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven.

题目链接:http://codeforces.com/contest/799/problem/A

分析:计算 不造第二台需要的时间还有造出第二台 做出一个蛋糕需要的时间  如果小于第一台需要的总时间 则YES

下面给出AC代码:

 

1 #include 
2 using namespace std; 3 int main() 4 { 5 int n,t,k,d; 6 while(scanf("%d%d%d%d",&n,&t,&k,&d)!=EOF) 7 { 8 int t1; 9 if(n%k==0)10 t1=n/k*t;11 else t1=(n/k+1)*t;12 int t2=d+t;13 if(t2

 

B. T-shirt buying

time limit per test:3 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values pi are distinct, and values ai and bi are integers from 1 to 3.

m buyers will come to the shop. Each of them wants to buy exactly one t-shirt. For the j-th buyer we know his favorite color cj.

A buyer agrees to buy a t-shirt, if at least one side (front or back) is painted in his favorite color. Among all t-shirts that have colors acceptable to this buyer he will choose the cheapest one. If there are no such t-shirts, the buyer won't buy anything. Assume that the buyers come one by one, and each buyer is served only after the previous one is served.

You are to compute the prices each buyer will pay for t-shirts.

Input

The first line contains single integer n (1 ≤ n ≤ 200 000) — the number of t-shirts.

The following line contains sequence of integers p1, p2, ..., pn (1 ≤ pi ≤ 1 000 000 000), where pi equals to the price of the i-th t-shirt.

The following line contains sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 3), where ai equals to the front color of the i-th t-shirt.

The following line contains sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 3), where bi equals to the back color of the i-th t-shirt.

The next line contains single integer m (1 ≤ m ≤ 200 000) — the number of buyers.

The following line contains sequence c1, c2, ..., cm (1 ≤ cj ≤ 3), where cj equals to the favorite color of the j-th buyer. The buyers will come to the shop in the order they are given in the input. Each buyer is served only after the previous one is served.

 

Output

Print to the first line m integers — the j-th integer should be equal to the price of the t-shirt which the j-th buyer will buy. If the j-th buyer won't buy anything, print -1.

Examples
Input
5 300 200 400 500 911 1 2 1 2 3 2 1 3 2 1 6 2 3 1 2 1 1
Output
200 400 300 500 911 -1
Input
2 1000000000 1 1 1 1 2 2 2 1
Output
1 1000000000

 题目链接:http://codeforces.com/contest/799/problem/B

分析:每人选择一件衣服  价钱最小的而且颜色有一面是自己喜欢的,用优先队列做的,看看就好

下面给出AC代码:

 

 

C. Fountains

time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes between the types are allowed.

Help Arkady to find two fountains with maximum total beauty so that he can buy both at the same time.

Input

The first line contains three integers n, c and d (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100 000) — the number of fountains, the number of coins and diamonds Arkady has.

The next n lines describe fountains. Each of these lines contain two integers bi and pi (1 ≤ bi, pi ≤ 100 000) — the beauty and the cost of the i-th fountain, and then a letter "C" or "D", describing in which type of money is the cost of fountain i: in coins or in diamonds, respectively.

Output

Print the maximum total beauty of exactly two fountains Arkady can build. If he can't build two fountains, print 0.

Examples
Input
3 7 6 10 8 C 4 3 C 5 6 D
Output
9
Input
2 4 5 2 5 C 2 1 D
Output
0
Input
3 10 10 5 5 C 5 5 C 10 11 D
Output
10
Note

In the first example Arkady should build the second fountain with beauty 4, which costs 3 coins. The first fountain he can't build because he don't have enough coins. Also Arkady should build the third fountain with beauty 5 which costs 6 diamonds. Thus the total beauty of built fountains is 9.

In the second example there are two fountains, but Arkady can't build both of them, because he needs 5 coins for the first fountain, and Arkady has only 4 coins.

题目链接:http://codeforces.com/contest/799/problem/C

题意:你有两种货币,每种只能买相应的东西,给了n个喷泉,每个喷泉有个漂亮值和价格以及你能用哪种货币买,

问用已拥有的货币你买两个喷泉,最大漂亮值多少

必须要买两个,买不起两个就是0

价格的范围很小,可以开个数组dp【i】记录i货币可以买的最大价值

分析:乱搞一下就可以了

下面给出AC代码:
1 #include
2 typedef long long ll; 3 using namespace std; 4 struct node 5 { 6 int p,b; 7 }cc[100050],dd[100050]; 8 int dp[2][100050]; 9 int cmp(node a,node b) 10 { 11 return a.b
>n>>c>>d; 19 for(i=0;i
0) 46 { 47 if(last>=cc[i].b) 48 { 49 if(dp[0][cc[i].b]!=0) 50 { 51 ans=max(ans,dp[0][cc[i].b]+cc[i].p); 52 } 53 } 54 else 55 { 56 if(dp[0][last]!=0) 57 ans=max(ans,dp[0][last]+cc[i].p); 58 } 59 } 60 for(j=cc[i].b;j<=cc[i+1].b;j++) 61 { 62 dp[0][j]=max(max(dp[0][j],dp[0][j-1]),cc[i].p); 63 } 64 } 65 for(i=0;i
0) 70 { 71 if(last>=dd[i].b) 72 { 73 if(dp[1][dd[i].b]!=0) 74 ans=max(ans,dp[1][dd[i].b]+dd[i].p); 75 } 76 else 77 { 78 if(dp[1][last]!=0) 79 ans=max(ans,dp[1][last]+dd[i].p); 80 } 81 } 82 for(j=dd[i].b;j<=dd[i+1].b;j++) 83 { 84 dp[1][j]=max(max(dp[1][j],dp[1][j-1]),dd[i].p); 85 } 86 } 87 if(ans==0&&(dp[0][c]==0||dp[1][d]==0)) 88 cout<<"0"<

 

              
       

           

 

               
       

           

转载于:https://www.cnblogs.com/ECJTUACM-873284962/p/6864378.html

你可能感兴趣的文章
前端优化及相关要点总结
查看>>
Vue 列表渲染
查看>>
struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)
查看>>
25 个精美的手机网站模板
查看>>
C#反射实例应用--------获取程序集信息和通过类名创建类实例
查看>>
VC中实现文字竖排的简单方法
查看>>
会话标识未更新
查看>>
【设计模式】数据访问对象模式
查看>>
Tomcat8 配置Oracle11g数据源
查看>>
【PHP面向对象(OOP)编程入门教程】8.构造方法__construct()与析构方法__destruct()
查看>>
ThinkPHP常用配置路径
查看>>
阿里架构师:程序员必须掌握的几项核心技术能力
查看>>
程序员常用的六大技术博客类
查看>>
vue中动画的实现的几种方式
查看>>
Iceworks 2.8.0 发布,自定义你的 React 模板
查看>>
胖哥学SpringMVC:请求方式转换过滤器配置
查看>>
Kotlin 更加优雅的 Builder - 理解 with
查看>>
前端日拱一卒D6——字符编码与浏览器解析
查看>>
python学习笔记- 多线程
查看>>
换一种思维看待PHP VS Node.js
查看>>