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. centos7 开机启动运行脚本

    /etc/profile.d 下建立一个xxxname.sh

  2. 阶段3 1.Mybatis_10.JNDI扩展知识_2 补充-JNDI搭建maven的war工程

    使用骨架 src下创建test目录 再新建java和resources两个Directory test下面创建java java的目录,让他作为源码的跟目录 test下的java文件夹 选择 完成之后 ...

  3. 阶段3 1.Mybatis_08.动态SQL_02.mybatis中动态sql语句-where标签的使用

    这里的userSex是实体类里面的属性名,而不是数据库内的字段名称 一个老王改成性别女,为了区分一下 增加sex字段的查询 where标签 用上where和刚才的执行效果是一样的 where标签使我们 ...

  4. java8 查找字符串中首次出现2次的字母

    利用java8的stream函数式编程进行处理 1.实现字母分离 map将整个字符串当成一个单词流来处理 Map<String[], Long> collect14 = Stream.of ...

  5. robotframework json解析

    用robotframework做接口测试,现在用的最多的就是json格式的数据,刚开始接触会感觉一脸懵逼,不知道怎么去取里面的值.在这里简单介绍一下,其实本身json取值不会太难,只要理解层次关系,一 ...

  6. 用apicloud+vue的VueLazyload实现缓存图片懒加载

    <script src="../../script/vue-lazyload.js"></script><img v-lazy="remot ...

  7. oracle ogg 单实例单向简单搭建测试(oracle-oracle)

    昨天突然接到消息说有一个线上的ogg出现了问题,看是否能修复,由于ogg以前玩的少,所以就加急搞了个测试环境,练习了一把 环境 db1,db2(单实例)ip: 1*,1*sid: orcl,ogg1o ...

  8. 3D打印技术的学习

    1. 我们使用3D建模软件:123Ddesign来设计 123D design软件保存格式有2种,分别为123dx和stl格式 123dx格式:选择菜单栏中“Save”下的“To my compute ...

  9. Go语言入门篇-环境准备

    一.GO语言特点 静态类型:首先要明确变量类型,如上所示. 编译型:指GO语言要被编译成机器能识别机器代码. GO语言开源. 编程范式:支持“函数式”和“面向对象” GO语言原生的支持并发编程:即GO ...

  10. java 中的equals()小结

    转载自http://www.cnblogs.com/jackyrong/archive/2006/08/20/481994.html Java中的equals是十分重要的,和= =要区别开来,最近在看 ...