Codeforces 899 1-N两非空集合最小差 末尾最多9对数计算 pair/链表加优先队列最少次数清空
A
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll LLmaxn = 2e18;
const int N = ;
int main()
{
int one = ;
int two = ;
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
int now;
cin >> now;
if (now == )
{
one++;
}
else
{
two++;
}
}
if (one < two)
{
cout << one << endl;
}
else
{
cout << two + (one - two) / << endl;
}
return ;
}
B
/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll LLmaxn = 2e18;
const int N = ;
int month1[] = {, , , , , , , , , , , , };
int month2[];
int now[];
int m[];
int cnt = ;
bool ok(int x)
{
if (x % == )
{
return true;
}
if (x % == && x % > )
{
return true;
}
return false;
}
int main()
{
for (int i = ; i <= ; i++)
{
month2[i] = month1[i];
}
month2[] = ;
for (int i = ; i <= ; i++)
{
if (ok(i))
{
for (int j = ; j <= ; j++)
{
now[++cnt] = month2[j];
}
}
else
{
for (int j = ; j <= ; j++)
{
now[++cnt] = month1[j];
}
}
}
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
cin >> m[i];
}
for (int i = ; i <= + ; i++)
{
for (int j = ; j <= n + ; j++)
{
if (j == n + )
{
cout << "Yes" << endl;
return ;
}
if (now[i + j] != m[j])
{
break;
}
}
}
cout << "No" << endl;
}
C
/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
const long long mod = 1e9 + ;
const int N = 1e6 + ;
vector<int> ans;
int main()
{
ll n;
cin >> n;
ll sum = (n + ) * n / ;
ll want = sum / ;
if (sum % )
{
cout << << endl;
for (int i = n; i >= ; i--)
{
if (i <= want)
{
ans.pb(i);
want -= i;
}
}
cout << ans.size() << " ";
for (int ch : ans)
{
cout << ch << " ";
}
cout << endl;
return ;
}
else
{
cout << << endl;
for (int i = n; i >= ; i--)
{
if (i <= want)
{
ans.pb(i);
want -= i;
}
}
cout << ans.size() << " ";
for (int ch : ans)
{
cout << ch << " ";
}
cout << endl;
return ;
}
}
D
/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
const long long mod = 1e9 + ;
const int N = 1e6 + ;
vector<int> ans;
int main()
{
ll now = ;
ll aim = ;
ll n;
cin >> n;
ll anser = ;
if (n < )
{
cout << (n - )*n / << endl;
return ;
}
while (n >= now)
{
now *= ;
aim++;
}
ll remain = ;
ll ten = ;
for (int i = ; i <= aim - ; i++)
{
remain *= ;
ten *= ;
remain += ;
}
//cout << remain << endl;
//cout << ten << endl;
ll cnt;
for (int i = ; i <= ; i++)
{
cnt = ten * i + remain;
if (n < (cnt + ) / )
{
break;
}
if (n >= cnt)
{
anser += 1LL * cnt / ;
}
else
{
anser += n + - (cnt + ) / ;
}
}
cout << anser << endl;
}
E
/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
const long long mod = 1e9 + ;
const int N = 2e5 + ;
int cnt = ;
int t1, t2;
int pre[N], Next[N], num[N], col[N];
priority_queue<pair<int, int> > que, del;
int main()
{
int anser = ;
int x;
int n;
cin >> n;
for (int i = ; i <= n; i++)
{
cin >> x;
if (x == col[cnt])
{
num[cnt]++;
}
else
{
col[++cnt] = x;
num[cnt] = ;
}
}
for (int i = ; i <= cnt; i++)
{
pre[i] = i - , Next[i] = i + ;
que.push(mkp(num[i], -i));
}
while (cnt)
{
while (!del.empty() && que.top() == del.top()) //如果区间已经被合并不存在
{
que.pop();
del.pop();
}
x = -que.top().second;
que.pop();
t1 = pre[x], t2 = Next[x];
Next[t1] = t2, pre[t2] = t1;
if (t1 && col[t1] == col[t2])
{
del.push(mkp(num[t2], -t2));
del.push(mkp(num[t1], -t1));
num[t1] += num[t2];
Next[t1] = Next[t2];
pre[Next[t2]] = t1;
que.push(mkp(num[t1], -t1));
cnt--;
}
cnt--;
anser++;
}
cout << anser << endl;
}
Codeforces 899 1-N两非空集合最小差 末尾最多9对数计算 pair/链表加优先队列最少次数清空的更多相关文章
- Servlet访问路径的两种方式、Servlet生命周期特点、计算服务启动后的访问次数、Get请求、Post请求
Servlet访问路径的两种方式: 1:注解 即在Servlet里写一个@WebServlet @WebServlet("/myServlet") 2:配置web.xml < ...
- 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离。显示为公里、米
/** * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离 * @param array $point_1 第1个点的x,y坐标 array( ...
- Codeforces 1089I - Interval-Free Permutations(析合树计数)
Codeforces 题面传送门 & 洛谷题面传送门 首先题目中涉及排列的 interval,因此可以想到析合树.由于本蒟蒻太菜了以至于没有听过这种神仙黑科技,因此简单介绍一下这种数据结构:我 ...
- java 对图片的添加文字描述,以及两张图片合成一张
最近公司一个需要,需要把商品的优惠卷分享链接,生成一个二维码然后和商品主图合成一张,并且在新合成的主图增加商品信息的描述,好了直接看合成后图片的样式 下面我就直接贴代码,首先是Contorller层 ...
- Codeforces 982 树边两端点计数偶数连通块 鲨鱼活动最小K最大location 扩展欧几里得方块内光线反射
A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...
- codeforces 上的找两人的幸运天
Bob and Alice are often participating in various programming competitions. Like many competitive pro ...
- Codeforces 899 F. Letters Removing (二分、树状数组)
题目链接:Letters Removing 题意: 给你一个长度为n的字符串,给出m次操作.每次操作给出一个l,r和一个字符c,要求删除字符串l到r之间所有的c. 题解: 看样例可以看出,这题最大的难 ...
- mysql两列合成一列
update manage set mark = concat(mark,remark) select concat(mark,remark) as pp from manage
- Codeforces 899 C.Dividing the numbers-规律
C. Dividing the numbers time limit per test 1 second memory limit per test 256 megabytes input s ...
随机推荐
- 方法二:Excel 2016 VBA工程密码破解
将你要破解的Excel文件关闭,切记一定要关闭呀!然后新建一个Excel文件 打开新建的这个Excel,按下alt+F11,打开vb界面,新建一个模块,如图所示 将代码复制到这个模块中,代码如下:Pr ...
- Python基本语法_函数_参数的多类型传值
前言 上一篇主要介绍了Python函数的参数类型,本篇继续学习Python函数多类型传值. 目录 前言 目录 软件环境 参数的多类型传值 向函数传递Tuple 向函数传递List 向函数传递Dicti ...
- Pycharm断点调试入门
断点调试是在开发过程中常用的功能,能清楚看到代码运行的过程,有利于代码问题跟踪.对我这个小白开发来说,还有一个作用是快速熟悉代码,拿到别人写的代码,有时看不太懂或看的很吃力,光这样看很无感,但是通过断 ...
- Centos 搭建DNS服务器
1:安装DNS服务 yum install bind -y 2:修改/etc/named.conf 配置文件 listen-on port 53 { any; }; listen-on-v6 port ...
- Web05_jQuery
在官方网站下载包,下载不带有min的包 http://jquery.com/download/ 案例一:使用JQ完成首页定时弹出广告图片 01_JQ入门 01_jQuery入门.html <!D ...
- 【SSM】---增删改查
20:43:06 package com.chinasofti.dao; import java.util.List; import com.chinasofti.entity.User; publi ...
- 用edoc2实现上传和下载
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.apache.http.Htt ...
- 手机app打开的web,在打开chrome浏览器
手机app打开的web在,打开chrome浏览器 <a href='intent://#Intent;action=android.intent.action.VIEW;scheme=googl ...
- docker 安装 gitlab 中文社区版
docker pull twang2218/gitlab-ce-zh 创建一个docker 目录 /usr/local/docker/gitlab 创建一个 docker-compose.yml ve ...
- 最新的省市编码和sql
下面的项目是整理的最新的省市编码sql文件,可以看看. github