CF940D Alena And The Heater
思路:
模拟。
实现:
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int a[], n;
string b;
int main()
{
while (cin >> n)
{
for (int i = ; i < n; i++) cin >> a[i];
cin >> b;
int l = -INF, r = INF;
for (int i = ; i < n; i++)
{
if (b[i] != b[i - ])
{
if (b[i] == '' && b[i - ] == '' && b[i - ] == '' && b[i - ] == '' && b[i - ] == '')
{
int tmp = INF; for (int j = i - ; j <= i; j++) tmp = min(tmp, a[j]);
if (r >= tmp) r = tmp - ;
}
else if (b[i] == '' && b[i - ] == '' && b[i - ] == '' && b[i - ] == '' && b[i - ] == '')
{
int tmp = -INF; for (int j = i - ; j <= i; j++) tmp = max(tmp, a[j]);
if (l <= tmp) l = tmp + ;
}
}
}
cout << l << " " << r << endl;
}
return ;
}
CF940D Alena And The Heater的更多相关文章
- 940D Alena And The Heater
传送门 题目大意 给出两个长度为N的数组A,B,以及一种计算规律: 若t[i]=1,需满足t[i-1]=t[i-2]=t[i-3]=t[i-4]=0,以及max{A[i],A[i-1],A[i-2], ...
- 「日常训练」Alena And The Heater (CFR466D2D)
题意(Codeforces 940D) 根据给定要求构建数列,求能构建出相同数列的l和r. 分析 这题写的是真的烦.一定要想到对b串要按照5个5个的看!为什么5个5个的看?因为根据题意,是先看前4个再 ...
- Codeforces Round #466 (Div. 2)
所有的题目都可以在CodeForces上查看 中间看起来有很多场比赛我没有写了 其实是因为有题目没改完 因为我不想改,所以就没有写了(大部分题目还是改完了的) 我还是觉得如果是打了的比赛就一场一场写比 ...
- Codeforces Round #466 (Div. 2) 题解
人生中第三次\(CF\)... 考试中切了\(A\)~\(E\) \(F\)题会做没时间写 题解 A:Points on the line 题意 给定一个数列,删最小的数,使最大差不大于一个定值 So ...
- Codeforces Round #466 (Div. 2) Solution
从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Nu ...
- 【codeforces】【比赛题解】#940 CF Round #466 (Div. 2)
人生的大起大落莫过如此,下一场我一定要回紫. [A]Points on the line 题意: 一个直线上有\(n\)个点,要求去掉最少的点,使得最远两点距离不超过\(d\). 题解: 暴力两重fo ...
- Codeforces Round #466
A. Points on the line 题意 给定一条直线上\(n\)个点,要求去掉最少的点,使得直线上相距最远的两个点的距离\(\leq d\). 思路 枚举长度为\(d\)的区间. Code ...
- ACM团队周赛题解(3)
940和822两套div.2 老规矩 #define MAXN 1000000+5#define MOD 1000000007#define PI (acos(-1.0))#define EPS 1e ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
随机推荐
- leetcode笔记:Majority Element
一. 题目描写叙述 Given an array of size n, find the majority element. The majority element is the element t ...
- linux driver开发
1 开发linux driver时的调试思路 基本上是打印调试,原因很简单,方便.或者使用工具挂住cpu.
- ubuntu删除ppa源
cd /etc/apt/sources.list.d 都在这里了 drwxr-xr-x 2 root root 4096 5月 22 23:41 ./ drwxr-xr-x 6 root root 4 ...
- JS数组array常用方法
JS数组array常用方法 1.检测数组 1)检测对象是否为数组,使用instanceof 操作符 if(value instanceof Array) { //对数组执行某些操作 } 2)获取对象的 ...
- Persisting Data to the Device
Persisting Data to the Device Edit PagePage History Overview The Android framework offers several op ...
- sizeof注意
1.sizeof用于获取非托管类型的大小(以字节为单位). 非托管类型包括下表列出的内置类型以及以下类型: 枚举类型 指针类型 用户定义的结构,不包含任何属于引用类型的字段或属性 struct ...
- LA 4670 Dominating Patterns (AC自动机)
题意:给定一个一篇文章,然后下面有一些单词,问这些单词在这文章中出现过几次. 析:这是一个AC自动机的裸板,最后在匹配完之后再统计数目就好. 代码如下: #pragma comment(linker, ...
- JNI编程(一) —— 编写一个最简单的JNI程序(转载)
转自:http://chnic.iteye.com/blog/198745 忙了好一段时间,总算得了几天的空闲.貌似很久没更新blog了,实在罪过.其实之前一直想把JNI的相关东西整理一下的,就从今天 ...
- 利用jenv安装maven, tomcat,zookeeper等
jenv有关的网站: http://jenv.io https://github.com/gcuisinier/jenv 1. 执行jenv安装 $ curl -L -s get.jenv.io | ...
- poj 2391 Ombrophobic Bovines【最大流】
我%--&(¥--,调了一下午,最后发现P赋值1e5能过,赋值1e6就会TLE致死.改了一下午加一晚上然而这是为什么??? 一种常见的建图套路,首先二分答案,注意上界要取大一点,1e9是不行的 ...