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

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. Android GreenDao 深查询 n:m 的关系

    在我的应用程序这样设计的关系:和我想选择至少一个用户作为一个朋友的所有聊天. 基本上,我想要执行以下查询:\ SELECT c.* FROM CHAT c, USER u, UserChats uc ...

  2. Sql 行转换为列 以及列转换为行的心得

    这是 创建数据库的脚本文件 CREATE TABLE [dbo].[stu]( [学号] [nvarchar](255) NOT NULL, [姓名] [nvarchar](255) NULL, [性 ...

  3. android sdk更新失败的解决方法

    [解决方法] 选择Tools-Options,在弹出的设置窗口中,「HTTP Proxy Server」和「HTTP Proxy Port」输入框内填入mirrors.neusoft.edu.cn和8 ...

  4. copyin函数

    详见:http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.kerneltechref%2Fdoc%2Fk ...

  5. elasticsearch最全详细使用教程:入门、索引管理、映射详解、索引别名、分词器、文档管理、路由、搜索详解

    一.快速入门1. 查看集群的健康状况http://localhost:9200/_cat http://localhost:9200/_cat/health?v 说明:v是用来要求在结果中返回表头 状 ...

  6. CAD交互绘制块引用对象(网页版)

    主要用到函数说明: _DMxDrawX::DrawBlockReference 绘制块引用对象.详细说明如下: 参数 说明 DOUBLE dPosX 插入点的X坐标 DOUBLE dPosY 插入点的 ...

  7. 实 Jordan 标准型和实 Weyr 标准型

    将学习到什么 本节讨论关于实矩阵的实形式的 Jordan 标准型,也讨论关于复矩阵的另外一种形式的 Jordan 标准型,因为它在与交换性有关的问题中很有用.   实 Jordan 标准型 假设 \( ...

  8. springboot-i18n国际化

    简介 In computing, internationalization and localization are means of adapting computer software to di ...

  9. Vue的响应式规则

    对象属性的响应规则 <body> <div id="root"> {{msg}} </div> </body> <script ...

  10. Python-求解两个字符串的最长公共子序列

    一.问题描述 给定两个字符串,求解这两个字符串的最长公共子序列(Longest Common Sequence).比如字符串1:BDCABA:字符串2:ABCBDAB.则这两个字符串的最长公共子序列长 ...