我从来没想过自己可以被支配的这么惨,大神讲这个场不容易掉分的啊

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 tminutes 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 ntkd (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.

这个A题我一直都不懂啊,就在那里猜意思,懂了又找不到怎么处理那四个数字,按理说样例都给的挺清楚的,但是自己就是一直wa,迷了一会才想到正确地打开方式。

#include<bits/stdc++.h>
using namespace std;
int main() {
int n,t,k,d;
cin>>n>>t>>k>>d;
int t1=n/k;
if(n%k==)
t1-=;
t1=t1*t;
if(t1>d&&k<n)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl; return ;
}
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 piai 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 
B题可以算数据结构的,意思就是一群人排队买衣服,买他喜欢的颜色的衣服,如果有多件符合,就买最便宜的,各种姿势各种T,我是感觉自己没有利用这个颜色数比较小的
条件,在随便搞,最后想想还是大神的队列比较好,本来我是觉得我可以重复处理起来比较麻烦,但是确实没有那么麻烦啊
#include <bits/stdc++.h>
using namespace std;
#define MN 200000
struct shirt{int p,a,b;}p[MN+];
bool cmp(shirt a,shirt b){return a.p<b.p;}
int u[MN+];
queue<int> v[];
int main()
{ std::ios::sync_with_stdio(false);
cin.tie();
int n,i;
cin>>n;
for(i=;i<=n;++i)cin>>p[i].p;
for(i=;i<=n;++i)cin>>p[i].a;
for(i=;i<=n;++i)cin>>p[i].b;
sort(p+,p+n+,cmp);
for(i=;i<=n;++i)
v[p[i].a].push(i),v[p[i].b].push(i);
cin>>i;
for(;i;i--)
{
cin>>n;
while(v[n].size()&&u[v[n].front()])v[n].pop();
if(v[n].size())cout<<p[v[n].front()].p<<"\n",u[v[n].front()]=;
else cout<<"-1\n";
}
}
tourist 的代码,思路更加清晰
#include <bits/stdc++.h>

using namespace std;

const int N = ;

set < pair <int, int> > s[];
int p[N], a[N], b[N];
bool alive[N]; int main() {
int n;
scanf("%d", &n);
for (int i = ; i < n; i++) {
scanf("%d", p + i);
}
for (int i = ; i < n; i++) {
scanf("%d", a + i);
}
for (int i = ; i < n; i++) {
scanf("%d", b + i);
}
for (int i = ; i < n; i++) {
s[a[i]].insert(make_pair(p[i], i));
s[b[i]].insert(make_pair(p[i], i));
alive[i] = true;
}
int tt;
scanf("%d", &tt);
while (tt--) {
int c;
scanf("%d", &c);
int ans = -;
while (!s[c].empty()) {
int x = (*(s[c].begin())).second;
s[c].erase(s[c].begin());
if (!alive[x]) {
continue;
}
alive[x] = false;
ans = p[x];
break;
}
printf("%d ", ans);
}
puts("");
return ;
}

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) 一夜回到小学生的更多相关文章

  1. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)(A.暴力,B.优先队列,C.dp乱搞)

    A. Carrot Cakes time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

  2. C.Fountains(Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)+线段树+RMQ)

    题目链接:http://codeforces.com/contest/799/problem/C 题目: 题意: 给你n种喷泉的价格和漂亮值,这n种喷泉题目指定用钻石或现金支付(分别用D和C表示),C ...

  3. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains 【树状数组维护区间最大值】

    题目传送门:http://codeforces.com/contest/799/problem/C C. Fountains time limit per test 2 seconds memory ...

  4. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) E - Aquarium decoration 贪心 + 平衡树

    E - Aquarium decoration 枚举两个人都喜欢的个数,就能得到单个喜欢的个数,然后用平衡树维护前k大的和. #include<bits/stdc++.h> #define ...

  5. 【动态规划】【滚动数组】【搜索】Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) D. Field expansion

    显然将扩张按从大到小排序之后,只有不超过前34个有效. d[i][j]表示使用前i个扩张,当length为j时,所能得到的最大的width是多少. 然后用二重循环更新即可, d[i][j*A[i]]= ...

  6. 【预处理】【分类讨论】Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains

    分几种情况讨论: (1)仅用C或D买两个 ①买两个代价相同的(实际不同)(排个序) ②买两个代价不同的(因为买两个代价相同的情况已经考虑过了,所以此时对于同一个代价,只需要保存美丽度最高的喷泉即可)( ...

  7. 树状数组 Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C. Fountains

    C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  8. Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) D. Field expansion

    D. Field expansion time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. Codeforces Round #413, rated, Div. 1 + Div. 2 C. Fountains(贪心 or 树状数组)

    http://codeforces.com/contest/799/problem/C 题意: 有n做花园,有人有c个硬币,d个钻石 (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100  ...

随机推荐

  1. Spring AOP初步总结(一)

    学习AOP有段时间了,一直没空总结一下,导致有些知识点都遗忘了,之后会把以前学过的Spring核心相关的知识点总结一轮... 先大体介绍下Spring AOP的特点(均摘自"Spring i ...

  2. 几款LINUX下的CHM查看器

    转帖地址:http://blog.csdn.net/aking21alinjuju/article/details/4436440 本文旨在介绍linux下的常见chm阅读软件及其安装,并针对一些问题 ...

  3. vue对象和视图

    1 Vue框架 1. vue 与 jQuery 区别 jQuery 仍然是操作DOM的思想, 主要jQuery 用来写页面特效 Vue是前端框架(MVVM) ,对项目进行分层. 处理数据 2 前端框架 ...

  4. mui开发中获取单选按钮、复选框的值

    js获取单选按钮的值 function getVals(){ var res = getRadioRes('rds'); if(res == null){mui.toast('请选择'); retur ...

  5. uvm_monitor——借我一双慧眼

    monitor 用来捕获(监视)和检查总线的信号是否满足预期的要求.所有的user_monitor 继承自uvm_monitor,uvm_monitor继承自uvm_component,从源代码来看里 ...

  6. hdu 3555 Bomb 炸弹(数位DP,入门)

    题意: 给一个数字n,求从1~n中有多少个数是含有49的,比如49,149,1490等都是含49的. 思路: 2^64也顶多是十进制的20多位,那么按十进制位来分析更简单.如果能计算k位十进制数中分别 ...

  7. ios项目icon和default图片命名规则

    一.应用图片标准iOS控件里的图片资源,苹果已经做了相应的升级,我们需要操心的是应用自己的图片资源.就像当初为了支持iPhone 4而制作的@2x高分辨率版本(译者:以下简称高分)图片一样,我们要为i ...

  8. 如何解决webpack中css背景图片的绝对地址

    在项目开发中,一般写相对路径是没有问题的,但是在项目比较大的情况下,我的scss文件可能为了方便管理,会放在不同的文件夹下,有的可能又不需要放在文件夹下,比如我的scss文件结构如下: module ...

  9. 浅谈web前端开发

    我个人认为前端攻城狮其实就是编程技术人员,用一句话来形容“比UI设计懂技术,比技术人员更懂交互”,当然也有人说前端工程师是工程师中的设计师,是设计师中的工程师. 好了废话不多说了,下面进入正题吧!   ...

  10. 2019的hdu暑假作业(欢迎纠错)

    1219 遍历计数. #include<bits/stdc++.h> #define QAQ 0 using namespace std; ]; ]; int main(){ )){ me ...