[每日一题2020.06.07]codeforces Round #627 (Div. 3)
problem A
/*
* Author: RoccoShi
* Time: 2020-06-07 19:37:51
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
int n, x, y, ans = 0;
cin >> n;
cin >> x;
n-=1;
while(n--)
{
cin >> y;
if(abs(y-x)%2!=0)
ans = 1;
}
if(ans == 1) cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
problem B
/*
* Author: RoccoShi
* Time: 2020-06-07 19:37:51
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[5005];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
while (t--)
{
int n; cin >> n;
int ans = 0;
for(int i = 0; i < n; ++i)
{
cin >> a[i];
}
int i = 0, j = n - 1;
while(i != n-2 && n >= 3)
{
if(a[j] == a[i])
ans++;
if(ans >= 1)break;
j--;
if(j == i + 1){
i++;
j = n - 1;
}
}
if(ans >= 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
problem C
/*
* Author: RoccoShi
* Time: 2020-06-07 19:37:51
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
int t;cin >> t;
while( t-- ){
int seq = 0, step = 1;
cin >> s;
for( int i = 0; i < s.size(); ++i){
if(s[i] == 'L')
seq++;
else if(s[i] == 'R')
seq = 0;
if(step - seq <= 0)
step++;
}
cout << step << endl;
}
return 0;
}
problem D
sort + 双指针
/*
* Author: RoccoShi
* Time: 2020-06-07 19:37:51
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
ll b;
ll tmp = 0, sum = 0, j = 0;
for(ll i = 0; i < n; ++i)
{
cin >> a[i];
}
for(ll i = 0; i < n; ++i)
{
cin >> b;
a[i] -= b;
}
sort(a, a + n);
for(ll i = n-1; i > 0; --i){
if(a[i] <= 0)
break;
while(a[i] + a[j] <= 0){
j++;
}
sum += (i - j);
tmp = 0;
}
cout << sum << endl;
return 0;
}
[每日一题2020.06.07]codeforces Round #627 (Div. 3)的更多相关文章
- [每日一题2020.06.11]Codeforces Round #644 (Div. 3) H
A-E见 : 这里 题目 我觉得很有必要把H拿出来单独发( 其实是今天懒得写题了 ) problem H 一个从 1 到 $ 2^m - 1$ 的长度为m的连续二进制序列, 删去指定的n个数, 问剩余 ...
- [每日一题2020.06.10]Codeforces Round #644 (Div. 3) ABCDEFG
花了5个多少小时总算把div3打通一次( 题目链接 problem A 题意 : 两个x*y的矩形不能重叠摆放, 要放进一个正方形正方形边长最小为多少 先求n = min(2x, 2y, x+y) 再 ...
- [每日一题2020.06.13]leetcode #739 #15 单调栈 双指针查找
739 每日温度 ( 单调栈 ) 题目 : https://leetcode-cn.com/problems/daily-temperatures/ 题意 : 找到数组每一个元素之后第一个大于它的元素 ...
- [每日一题2020.06.17] leetcode周赛T3 5438 制作m束花所需的最少天数 二分搜索
题目链接 这题我开始一直在想如何在数组上dp操作搜索区间, 很蠢, 实际上用二分查找的方法可以很快的解决 首先我们通过一个函数判断第x天是否符合题意, 如果x天可以做出m束花, 那么大于m的天数必然可 ...
- [每日一题2020.06.14]leetcode #70 爬楼梯 斐波那契数列 记忆化搜索 递推通项公式
题目链接 题意 : 求斐波那契数列第n项 很简单一道题, 写它是因为想水一篇博客 勾起了我的回忆 首先, 求斐波那契数列, 一定 不 要 用 递归 ! 依稀记得当年校赛, 我在第一题交了20发超时, ...
- [每日一题2020.06.08]洛谷P1605 DFS
今天cf又杯具的只写出2题, 虽然AB题20分钟左右就搞定了, 但是CD写了2个小时也没写出来 D题我用到了DFS, 虽然必不正确, 但是我至少发现了一个问题, 那就是我连DFS都忘了, 于是怒找DF ...
- [每日一题2020.06.16] leetcode双周赛T3 5423 找两个和为目标值且不重叠的子数组 DP, 前缀和
题目链接 给你一个整数数组 arr 和一个整数值 target . 请你在 arr 中找 两个互不重叠的子数组 且它们的和都等于 target .可能会有多种方案,请你返回满足要求的两个子数组长度和的 ...
- [每日一题2020.06.15]P1226 【模板】快速幂取余运算
我是题目 快速幂就是快速求 \(a^b\)的一种算法 快速幂 思想 : 比如我要求 \(6^9\) 首先将幂转化为二进制形式 : \[6^9 = 6^{1001} \tag{1} \] 可以得到 : ...
- [每日一题2020.06.12]P3375 【模板】KMP字符串匹配
题目链接 关于kmp : https://www.cnblogs.com/roccoshi/p/13096988.html 关于kmp, 想了很久, 我觉得不应该放在这里写, 另开一贴记录一下. #i ...
随机推荐
- 【1-n】区间覆盖 TOJ4168+BZOJ1192
Xiao Ming is very interesting for array. He given a sorted positive integer array and an integer n. ...
- Linux上,最常用的一批命令解析【10年精选】
原文链接:https://mp.weixin.qq.com/s/QkqHexs_kOgy_5OwbwyFww 建议点击原文链接查看 不同平台linux客户端连接工具分享: windos终端神器:SSH ...
- elasticsearch7.X x-pack破解
简介: x-pack是elasticsearch的一个收费的扩展包,将权限管理,警告,监视等功能捆绑在一个易于安装的软件包中,x-pack被设计为一个无缝的工作,但是你可以轻松的启用或者关闭一些功能. ...
- Rocket - debug - TLDebugModuleInner - DMSTATUS
https://mp.weixin.qq.com/s/GyGriFyeq_7Z3xOjKn56Mg 简单介绍TLDebugModuleInner中DMSTATUS寄存器的实现. 1. DMSTATUS ...
- Rocket - tilelink - FIFOFixer
https://mp.weixin.qq.com/s/JS4Pguwa6LXjPsMq6nW8HA 简单介绍FIFOFixer的实现. 1. 基本介绍 按照一定的策略把某一部分m ...
- Rocket - tilelink - Atomics
https://mp.weixin.qq.com/s/TSwKL_qm-b-0e8x7r--hhg 简单介绍Atomics中数学运算.逻辑运算的实现. 1. io Atomics ...
- Javascript中target事件属性,事件的目标节点的获取。
window.event.srcElement与window.event.target 都是指向触发事件的元素,它是什么就有什么样的属性 srcElement是事件初始化目标html元素对象引用,因为 ...
- Java 解析 XML文件
个人博客网:https://wushaopei.github.io/ (你想要这里多有) package com.example.poiutis.xml; import com.example ...
- 自制基于python的DoU log分析脚本
工作中测试DoU的log需要分析,原先是使用excel,去ctrl c,ctrl v截取数据,整理格式等等.一来,这工作虽然很简单,但是非常耗时,不熟练的人(比如我)一搞搞个半天:二来,不小心还会出现 ...
- Java实现 LeetCode 730 统计不同回文子字符串(动态规划)
730. 统计不同回文子字符串 给定一个字符串 S,找出 S 中不同的非空回文子序列个数,并返回该数字与 10^9 + 7 的模. 通过从 S 中删除 0 个或多个字符来获得子字符序列. 如果一个字符 ...