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的更多相关文章

  1. Atcoder Grand Contest 024 E - Sequence Growing Hard(dp+思维)

    题目传送门 典型的 Atcoder 风格的计数 dp. 题目可以转化为每次在序列中插入一个 \([1,k]\) 的数,共操作 \(n\) 次,满足后一个序列的字典序严格大于前一个序列,问有多少种操作序 ...

  2. Atcoder Grand Contest 024

    A 略 B 略 C 略 D(构造分形) 题意: 给出一个由n个点的组成的树,你可以加一些点形成一个更大的树.对于新树中的两个点i和j,如果以i为根的树与以j为根的树是同构的那么i和j颜色可以相同.问最 ...

  3. [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. ...

  4. NSThread 子线程 Cocoa NSOperation GCD(Grand Central Dispatch) 多线程

    单词:thread 英 θred:n 线.思路.vt 穿过.vi 穿透过 一.    进程.线程 进程:正在进行中的程序被称为进程,负责程序运行的内存分配,每一个进程都有自己独立的虚拟内存空间 线程: ...

  5. 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 ...

  6. 在Swift中应用Grand Central Dispatch(上)转载自的goldenfiredo001的博客

    尽管Grand Central Dispatch(GCD)已经存在一段时间了,但并非每个人都知道怎么使用它.这是情有可原的,因为并发很棘手,而且GCD本身基于C的API在 Swift世界中很刺眼. 在 ...

  7. Grand Central Dispatch (GCD)

    Grand Central Dispatch (GCD) Reference Grand Central Dispatch (GCD) comprises language features, run ...

  8. 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 ...

  9. php大力力 [024节]PHP中的字符串连接操作(2015-08-27)

    2015-08-27 php大力力024.PHP中的字符串连接操作 PHP中的字符串连接操作  阅读:次   时间:2012-03-25 PHP字符串的连接的简单实例 时间:2013-12-30 很多 ...

随机推荐

  1. Mac 安装 Novicat

    https://blog.csdn.net/jor_ivy/article/details/81323199 详细见这篇文章

  2. CSS 解决 a标签去掉下划线 text-decoration: none无效 的解决方案

    经过查阅,如果想要去掉a标签的默认效果,就要用text-decoration: none;,但是经过试验发现并不好用,可能是因为你用a标签里的class或id定义的CSS样式,就像这样: <di ...

  3. git提交到分支

    git checkout grego@gregoo:mygo$ git checkout origin/test Note: checking out 'origin/test'. You are i ...

  4. Solr安装并导入mysql数据

    参考博客:https://blog.csdn.net/u013160017/article/details/81037279 下载地址:https://lucene.apache.org/solr/m ...

  5. MEF引起的内存泄露

    也许你编程的时候很小心,注意不引起内存泄露,例如不要被全局Static的变量引用上,注意Singleton的static引用,注意Event Handler注销,注意IDisposable接口实现,而 ...

  6. 三十八:数据库之ORM层面删除数据的注意事项

    准备工作 from sqlalchemy import create_engine, Column, Integer, String, Float, Text, ForeignKeyfrom sqla ...

  7. 二十九:数据库之SQLAlchemy连接数据库

    手写SQL复用性不高,SQL越复杂越容易出bug,而且容易引起SQL注入,所以现在Ibanez使用orm框架将数据库映射为数据模型,这是使用SQLAlchemy 准备工作,安装SQLAlchemy和P ...

  8. LeetCode.993-二叉树中的堂兄弟(Cousins in Binary Tree)

    这是悦乐书的第374次更新,第401篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第235题(顺位题号是993).在二叉树中,根节点在深度0处,并且每个深度为k的节点的子 ...

  9. 安装opencv3.3.0碰到的问题及解决方法

    出处:http://osask.cn/front/ask/view/258965 CMakeError.log Compilation failed: source file: '/home/jhro ...

  10. CSS:文字水平居中的写法

    <view class='kk'> 水平垂直居中文字 </view> .kk{ border: 1px solid #000000; width: 200px; height: ...