博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #345 (Div. 2) D. Image Preview 暴力 二分
阅读量:7048 次
发布时间:2019-06-28

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

D. Image Preview

题目连接:

Description

Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a seconds to swipe from photo to adjacent.

For each photo it is known which orientation is intended for it — horizontal or vertical. Phone is in the vertical orientation and can't be rotated. It takes b second to change orientation of the photo.

Vasya has T seconds to watch photos. He want to watch as many photos as possible. If Vasya opens the photo for the first time, he spends 1 second to notice all details in it. If photo is in the wrong orientation, he spends b seconds on rotating it before watching it. If Vasya has already opened the photo, he just skips it (so he doesn't spend any time for watching it or for changing its orientation). It is not allowed to skip unseen photos.

Help Vasya find the maximum number of photos he is able to watch during T seconds.

Input

The first line of the input contains 4 integers n, a, b, T (1 ≤ n ≤ 5·105, 1 ≤ a, b ≤ 1000, 1 ≤ T ≤ 109) — the number of photos, time to move from a photo to adjacent, time to change orientation of a photo and time Vasya can spend for watching photo.

Second line of the input contains a string of length n containing symbols 'w' and 'h'.

If the i-th position of a string contains 'w', then the photo i should be seen in the horizontal orientation.

If the i-th position of a string contains 'h', then the photo i should be seen in vertical orientation.

Output

Output the only integer, the maximum number of photos Vasya is able to watch during those T seconds.

Sample Input

4 2 3 10

wwhw

Sample Output

2

Hint

题意

有n张照片,你看一张照片需要1秒,你滑动照片到左边或者右边,需要a秒,翻转照片需要b秒,问你在T秒内最多看多少张照片

照片必须看,不能跳过。

手机是h的,一直保持着h不变。

题解:

暴力枚举左边看多少张,然后二分右边最多看多少张

暴力枚举右边看多少张,然后二分左边。

具体实现,就当成模拟题去做吧……

代码

#include
using namespace std;const int maxn = 5e5+7;int n,a,b,T;string s;int d[maxn],d2[maxn];int check(char k){ if(k=='w')return 0; else return 1;}int update(int x,int y){ if(x+y>1e9)return 1e9+1; return x+y;}int main(){ scanf("%d%d%d%d",&n,&a,&b,&T); T+=a; cin>>s; int now = 1; for(int i=0;i

转载地址:http://zqzol.baihongyu.com/

你可能感兴趣的文章
Linux快捷键
查看>>
文档对象模型DOM
查看>>
2019北京国际康复及个人健康博览会将在中国国际展览中心举办
查看>>
JVM——类加载机制(一)
查看>>
超清晰的 DNS 原理入门指南 (资源)
查看>>
大神笔记
查看>>
spring cloud构建java b2b2c 电子商务云商平台
查看>>
阿里顶级Java架构师,教你这样手写Spring!
查看>>
android课程表控件、悬浮窗、Todo应用、MVP框架、Kotlin完整项目源码
查看>>
CLOB字段在java中操作
查看>>
磁盘清理
查看>>
javascript 判断数据类型 判空
查看>>
matplotlib 中文字体问题
查看>>
protobuf v3测试
查看>>
(1)知识准备【利用objective-c的runtime特性,结合FMDB实现一个轻量级的ORM】
查看>>
Angular js开发的各种坑(持续更新中。。。)
查看>>
Google Apps - Gmail API的通知功能
查看>>
调试java8 函数式
查看>>
Intellij使用心得(二) -- 关于启动Web服务器的几个事
查看>>
linux源代码安装软件
查看>>