Codeforces 957 水位标记思维题
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 水位标记思维题的更多相关文章
- CF--思维练习-- CodeForces - 215C - Crosses(思维题)
ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...
- Codeforces 675C Money Transfers 思维题
原题:http://codeforces.com/contest/675/problem/C 让我们用数组a保存每个银行的余额,因为所有余额的和加起来一定为0,所以我们能把整个数组a划分为几个区间,每 ...
- 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 ...
- codeforces 1140D(区间dp/思维题)
D. Minimum Triangulation time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- ACM思维题训练 Section A
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...
- codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...
- 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas
题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...
- 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 ...
- CodeForces - 631C ——(思维题)
Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...
随机推荐
- HDU6623 思维题(n分解成质因子的形式,问最小的幂是多少)
题目大意:给你一个数n,把它分解为素数的幂次的乘积的形式:n=p1^e1 * p2^e2 * .......pk^ek 求最小的幂次是多少 n=le18 分析: 首先我们肯定是不可以枚举1e18的因 ...
- 每日踩坑 2019-07-30 H5 使用 iframe 底部有白边
用个iframe累死累活的 用 js 动态计算高度, 结果明明px都对,然后却把页面滚动条也整出来了. 查看元素盒模型也一切正常. 然后仔细观察就发现是下边多了几个像素的白色边. 然后就 百度呗 以下 ...
- tp3.2 页面Windows正常 linux异常,页面找不到
这个问题主要是tp3.2 在读取控制器里的方法时,会把方法自动转为小写, 然后去对应view成找html文件,自然找不到. class textController extends ComContro ...
- 一、基础篇--1.1Java基础-反射的用途和实现
https://blog.csdn.net/SongYuxinIT/article/details/81872066 反射的核心是JVM在运行时才动态加载类或调用方法/访问属性,它不需要事先(写代码的 ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jeewx.weixin_account_user_relation' doesn't exist
[INFO] Scanning for projects...[INFO] [INFO] ------------------------------------------------------- ...
- 【Qt开发】事件循环与线程 一
事件循环与线程 一 初次读到这篇文章,译者感觉如沐春风,深刻体会到原文作者是花了很大功夫来写这篇文章的,文章深入浅出,相信仔细读完原文或下面译文的读者一定会有收获. 由于原文很长,原文作者的行文思路是 ...
- C# 编写的webservice 怎样返回XML数据
[WebMethod] public string GetXml() { string sConStr = ConfigurationManager.ConnectionStrings["c ...
- Marked Ancestor
一道并查集的题目硬是被我当成线段树写了,感觉这样写虽然不是最好的,不过能a就行 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=103906 ...
- 成功安装 Visio 2016 和 Office 2016 的64位版本~~
.XML是个很 的东西!!! 折腾了一下 Visio 2016_x64 和 Office 2016_x64,功夫不负! 首先,选对配置工具很重要. 之前总是失败是因为在官网下载的配置工具是给2019 ...
- int快读
昨天偶然间看到CJ_tony的快读,所以便决定学习一下. 这个快读的原理就是:读入单个字符要比读入读入数字快,先读入字符,然后再转化成数字.(原理的话大学再研究) 代码: #include<io ...