At grand 024
A
/* 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
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
using namespace std;
typedef long long ll;
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
const long long mod = 1e9 + ;
const int N = 1e5 + ;
int main()
{
ll a, b, c, k;
cin >> a >> b >> c >> k;
if (k % == )
{
cout << b - a << endl;
}
else
{
cout << a - b << endl;
}
return ;
}
B
只要算出最长 数字连续子序列就可以了
/* 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
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
using namespace std;
typedef long long ll;
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
const long long mod = 1e9 + ;
const int N = 2e5 + ;
int n;
int num[N];
int aim[N];
int main()
{
read(n);
int now;
for (int i = ; i <= n; i++)
{
read(now);
num[now] = i;
}
int ans = ;
int ansmaxn = ;
for (int i = ; i <= n; i++)
{
if (num[i] > num[i - ])
{
ans++;
}
else
{
ans = ;
}
ansmaxn = max(ansmaxn, ans);
}
cout << n - ansmaxn << endl;
return ;
}
C
给你两个数组A,B A全为0 B是给定的N个数
一次操作可以使得Ai(2<=i<=N) 变为 Ai-1+1
解:
首先排除不合法的情况: ①.当A0不为0的时候 ②.当前面的数减后面的数大于1的时候
/* 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
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
using namespace std;
typedef long long ll;
inline void read(int &v)
{
v = ;
char c = ;
int p = ;
while (c < '' || c > '')
{
if (c == '-')
{
p = -;
}
c = getchar();
}
while (c >= '' && c <= '')
{
v = (v << ) + (v << ) + c - '';
c = getchar();
}
v *= p;
}
const long long mod = 1e9 + ;
const int N = 2e5 + ;
int n;
ll num[N];
int main()
{
read(n);
for (int i = ; i <= n; i++)
{
cin >> num[i];
}
if (num[] != )
{
cout << - << endl;
return ;
}
for (int i = ; i <= n; i++)
{
if (num[i] - num[i - ] > )
{
cout << - << endl;
return ;
}
}
ll anser = ;
for (int i = ; i <= n; i++)
{
if (num[i] == num[i - ] + )
{
anser++;
}
else
{
anser += num[i];
}
}
cout << anser << endl;
return ;
}
D
At grand 024的更多相关文章
- Atcoder Grand Contest 024 E - Sequence Growing Hard(dp+思维)
题目传送门 典型的 Atcoder 风格的计数 dp. 题目可以转化为每次在序列中插入一个 \([1,k]\) 的数,共操作 \(n\) 次,满足后一个序列的字典序严格大于前一个序列,问有多少种操作序 ...
- Atcoder Grand Contest 024
A 略 B 略 C 略 D(构造分形) 题意: 给出一个由n个点的组成的树,你可以加一些点形成一个更大的树.对于新树中的两个点i和j,如果以i为根的树与以j为根的树是同构的那么i和j颜色可以相同.问最 ...
- [AtCoder Grand Contest 024 Problem E]Sequence Growing Hard
题目大意:考虑 N +1 个数组 {A0,A1,…,AN}.其中 Ai 的长度是 i,Ai 内的所有数字都在 1 到 K 之间. Ai−1 是 Ai 的子序列,即 Ai 删一个数字可以得到 Ai−1. ...
- NSThread 子线程 Cocoa NSOperation GCD(Grand Central Dispatch) 多线程
单词:thread 英 θred:n 线.思路.vt 穿过.vi 穿透过 一. 进程.线程 进程:正在进行中的程序被称为进程,负责程序运行的内存分配,每一个进程都有自己独立的虚拟内存空间 线程: ...
- Reading With Purpose: A grand experiment
Reading With Purpose: A grand experiment This is the preface to a set of notes I'm writing for a sem ...
- 在Swift中应用Grand Central Dispatch(上)转载自的goldenfiredo001的博客
尽管Grand Central Dispatch(GCD)已经存在一段时间了,但并非每个人都知道怎么使用它.这是情有可原的,因为并发很棘手,而且GCD本身基于C的API在 Swift世界中很刺眼. 在 ...
- Grand Central Dispatch (GCD)
Grand Central Dispatch (GCD) Reference Grand Central Dispatch (GCD) comprises language features, run ...
- iOS 中NSOperationQueue,Grand Central Dispatch , Thread的上下关系和区别
In OS X v10.6 and later, operation queues use the libdispatch library (also known as Grand Central D ...
- php大力力 [024节]PHP中的字符串连接操作(2015-08-27)
2015-08-27 php大力力024.PHP中的字符串连接操作 PHP中的字符串连接操作 阅读:次 时间:2012-03-25 PHP字符串的连接的简单实例 时间:2013-12-30 很多 ...
随机推荐
- leecode 309. 最佳买卖股票时机含冷冻期
/***** //sell[i]表示截至第i天,最后一个操作是卖时的最大收益: //buy[i]表示截至第i天,最后一个操作是买时的最大收益: //cool[i]表示截至第i天,最后一个操作是冷冻期时 ...
- Nginx负载均衡服务器实现会话粘贴的几种方式
1. 使用Nginx 的ip_hash作为负载均衡服务并支持Session sticky 2. 使用nginx sticky第三方模块实现基于cookie的负载均衡 3.使用nginx的map指令根据 ...
- harbor仓库安装
https://6xyun.cn/article/50 环境: 192.168.0.65 harbor .docker 一.安装相关依赖 .安装Docker Docker 使用离线版docker-ce ...
- CSS 易混淆属性
1. div中 height和line-height的区别 <div style="height:120px;">是用来规定整个div的高度,文字还是默认会在顶端开始向 ...
- Linux配置全局jdk以及Tomcat服务器简单测试
Linux配置全局jdk 1.确保相应文件夹下有apache-tomcat和jdk的压缩文件 注意:jdk文件必须为适应Linux版本的文件 (如果已经有了相应文件,可以跳过以下第2-3个步骤) 2. ...
- centos7.5 升级kernel内核版本
一,查看当前系统内核版本信息 awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 或 ...
- 【推荐算法工程师技术栈系列】程序语言--Java
目录 JDK 初步 ArrayList LinkedList Vector Stack HashMap Hashtable LinkedHashMap TreeMap HashSet LinkedHa ...
- sublime3配置php开发环境
Sublime3 3143 1.用包管理器安装SublimeLinter ctrl+shift+p Package Control: install package SublimeLinter 注意: ...
- Linux用ICMP协议实现简单Ping网络监测功能
ICMP是(Internet Control Message Protocol)Internet控制报文协议.它是TCP/IP协议族的一个子协议,用于在IP主机.路由器之间传递控制消息.控制消息是指网 ...
- etcd集群添加节点
查看当前集群节点信息 # etcdctl member list --write-out=table +------------------+---------+------------------- ...