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

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. JS实现的图片预览功能

    之前的博文有实现过图片上传预览,但那种方法是预览时就将图片上传,会产生很大的浪费空间.找到了之前有人写的用JS实现的图片预览,就说用js将上传的图片显示,上传代码在之前的博文中有写到. 以下是实现的代 ...

  2. Android 权限的实现

    1.    权限 每个程序在安装时都有建立一个系统ID,如app_15,用以保护数据不被其它应用获取.Android根据不同的用户和组,分配不同权限,比如访问SD卡,访问网络等等.底层映射为Linux ...

  3. Azure Powershell blob中指定的vhd创建虚拟机

    #此脚本用于 Azure 存储账户中已有 vhd 镜像文件创建虚拟机,一般用于做好镜像测试 #----------------------------------------------------- ...

  4. moment算本月开始日期和结束日期

    moment算本月开始日期和结束日期 1.引入moment.js var vStartDate=new moment().add('month',addMonth).format("YYYY ...

  5. 洛谷 P1449 后缀表达式

    题目描述 所谓后缀表达式是指这样的一个表达式:式中不再引用括号,运算符号放在两个运算对象之后,所有计算按运算符号出现的顺序,严格地由左而右新进行(不用考虑运算符的优先级). 如:3*(5–2)+7对应 ...

  6. LibreOJ #103. 子串查找

    题目描述 这是一道模板题. 给定一个字符串 A AA 和一个字符串 B BB,求 B BB 在 A AA 中的出现次数. A AA 中不同位置出现的 B BB 可重叠. 输入格式 输入共两行,分别是字 ...

  7. int型除以int型

    int型除以int型得到的还是int型 就算你是这样的:float a = 5/3,虽然你定义的a是float型,但a得到的结果依旧是1.0000而不是1.66666 5/3先得到1,然后再转换成1. ...

  8. python常用模块之json和pickle模块

    json模块 json.dumps     将 Python 对象编码成 JSON 字符串 json.loads       用于解码 JSON 数据.该函数返回 Python 字段的数据类型. pi ...

  9. bootstrap table 保留翻页选中数据

    $(function () { $('#exampleTable').on('uncheck.bs.table check.bs.table check-all.bs.table uncheck-al ...

  10. Java中的线程--线程范围内共享数据

    接着学习Java中的线程,线程范围内的共享数据! 一.线程范围内的数据共享定义 对于相同的程序代码,多个模块在同一个线程中共享一份数据,而在另外线程中运行时又共享另外一份数据. 共享数据中存在的问题, ...