A

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
string a;
int anser = ;
int main()
{
int n;
cin >> n;
cin >> a;
int len = a.size();
for (int i = ; i < len - ; i++)
{
if (a[i] == a[i + ] && a[i] != '?')
{
cout << "No" << endl;
return ;
}
}
if (a[] == '?' || a[len - ] == '?')
{
cout << "Yes" << endl;
return ;
}
for (int i = ; i < len - ; i++)
{
if (a[i] == '?' && (a[i - ] == a[i + ]))
{
cout << "Yes" << endl;
return ;
}
}
for (int i = ; i < len - ; i++)
{
if (a[i] == a[i + ] && a[i] == '?')
{
cout << "Yes" << endl;
return ;
}
}
cout << "No" << endl;
}

B

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
char f[][];
int hang[];
int main()
{
int n, m;
int sum = ;
cin >> n >> m;
for (int i = ; i <= n; i++)
{
scanf("%s", f[i] + );
}
for (int i = ; i <= n; i++)
{
if (hang[i])
{
continue;
}
for (int j = ; j <= m; j++)
{
if (f[i][j] == '#')
{
//cout << i << " " << j << endl;
for (int k = ; k <= n; k++)
{
if (k == i)
{
continue;
}
if (f[k][j] == '#')
{
// cout << "find" << k << " " << j << endl;
for (int w = ; w <= m; w++)
{
if (f[k][w] != f[i][w])
{
cout << "No" << endl;
return ;
}
}
hang[k] = ;
}
}
}
}
}
cout << "Yes" << endl;
return ;
}

C

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[];
int main()
{
double anser = -;
int n, u;
cin >> n >> u;
num[n + ] = INT_MAX;
for (int i = ; i <= n; i++)
{
scanf("%d", num + i);
}
for (int i = ; i <= n - ; i++)
{
int now = num[i];
int cha = num[i + ] - num[i];
int aim = upper_bound(num + , num + n + , num[i] + u) - num - ;
if (aim - i <= || aim > n)
{
continue;
}
//cout << i << " " << aim << endl;
anser = max(anser, (double)(num[aim] - num[i] - cha) / (double)(num[aim] - num[i]));
}
if (anser == -)
{
cout << anser << endl;
}
else
{
printf("%.10f\n", anser);
}
return ;
}

D

假设在第i次量的时候的总标记数为sum[i] 可知其必定为非递减函数 sum[i]=d[i]+m[i]+1

要使d[i]的总值最小则 要在m[i]+1上面再加数使得 m[i]>=m[i-1]&&m[i+1]-1<=m[i]<=m[i+1]

先从前往后扫一遍满足第一个条件 再从往前扫一遍满足第二个条件

注意要开LL

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
ll num[];
int main()
{
int n;
cin >> n;
ll maxn = - ;
ll ans = ;
for (int i = ; i <= n; i++)
{
scanf("%lld", num + i);
maxn = max(maxn, num[i]);
}
for (int i = ; i <= n - ; i++)
{
if (num[i + ] < num[i])
{
ans += num[i] - num[i + ];
num[i + ] = num[i];
}
}
for (int i = n; i >= ; i--)
{
if (num[i] - num[i - ] > )
{
ans += num[i] - - num[i - ];
num[i - ] = num[i] - ;
}
}
cout << ans << endl;
return ;
}

Codeforces 957 水位标记思维题的更多相关文章

  1. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

  2. Codeforces 675C Money Transfers 思维题

    原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...

  3. Codeforces 1090D - Similar Arrays - [思维题][构造题][2018-2019 Russia Open High School Programming Contest Problem D]

    题目链接:https://codeforces.com/contest/1090/problem/D Vasya had an array of n integers, each element of ...

  4. codeforces 1140D(区间dp/思维题)

    D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

  6. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  7. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  8. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  9. CodeForces - 631C ——(思维题)

    Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...

随机推荐

  1. rsync aws ec2 pem

    How to use aws ec2 pem http://www.anthonychambers.co.uk/blog/rsync-to-aws-ec2-using-.pem-key/9 方法如下: ...

  2. git连接远程仓库时,出现“ Repository not found"的解决办法

    2018-08-25 今天连接远程仓库时,出现: 原来是远程仓库地址名字错了. 解决方法: 1.找到.git目录 2.进入.git找到config文件 3.修改config里面的远程地址url

  3. mysql修改数据表某列的配置

    alter table 表名 modify column 字段名 类型;alter table 表名 drop column 字段名

  4. 十四、RF中SSHLibrary库介绍

    A.安装SSHLibrary:   pip2 install robotframework-sshlibrary   (导入SSHLibrary) B.远程连接linux服务器 1.#连接linux服 ...

  5. 初学单片机:Proteus介绍、Proteus与Keil联调(Windows10环境下)

    Proteus是一个仿真软件,可以在里面设计电路并模拟测试,也可生成PCB的布线等等,反正就是强大的不行.初学单片机,除了开发板,这个仿真器就是一个很好的调式环境.软件安装信息: Proteus 8. ...

  6. java.io.FileNotFoundException: /usr/local/hadoop/logs/fairscheduler-statedump.log(权限不够)解决方案

    问题描述:Linux虚拟机内使用hadoop 解决方案: $ su 密码:****** # chown hadoop 文件名 进入超级管理员,为hadoop用户分配该文件的权限. 完美解决:

  7. 多变量分析绘图(hue参数)以及盒图和小提琴图

    1,函数stipplot() stipplot()函数用来画散点图,其x轴是离散型的变量 直接上代码 import seaborn as sns import numpy as np import p ...

  8. HTTP 常见相应状态码及含义

    1xx:信息 100 Continue 服务器仅接收到部分请求,但是一旦服务器并没有拒绝该请求,客户端应该继续发送其余的请求. 101 Switching Protocols 服务器转换协议:服务器将 ...

  9. Docker网络大揭秘(单机)

    docker网络官网 https://docs.docker.com/network/ Docker容器和服务如此强大的原因之一是您可以将它们连接在一起,或将它们连接到非Docker工作负载.Dock ...

  10. 最少多少人说谎(dp)

    https://ac.nowcoder.com/acm/contest/1168/H 题意:n个学生,邓志聪想知道这些学生的考试情况,于是一个一个叫这些学生叫去办公室问他们,但是有些学生并没有讲真话, ...