首页 技术 正文
技术 2022年11月6日
0 收藏 422 点赞 437 浏览 5061 个字

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

A. Carrot Cakestime 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”.

Examplesinput

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 buyingtime 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.

Examplesinput

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 ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905