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 很多 ...
随机推荐
- Mac 安装 Novicat
https://blog.csdn.net/jor_ivy/article/details/81323199 详细见这篇文章
- Jquery退出循环
返回falsh即可 return false; 如果return true; 则进入下一次循环
- <img>的title和alt有什么区别
1.title是全局属性之一,用于为元素提供附加的advisory information.通常当鼠标滑动到元素上的时候显示. 2.alt是<img>的特有属性,是图片内容的等价描述,用于 ...
- warning: accessed via instance reference
提示如图: 先简单翻译一下: 静态成员***通过实例对象访问 显示通过类实例而不是类本身调用方法和属性. 现有一个类Test,有静态方法methods和静态属性fields. 对于静态变量或方法,推荐 ...
- Pycharm 常用快捷键-Windows版
常用快捷键: Ctrl + / 行注释(可选中多行) Ctrl + Alt + L 代码格式化 Tab / Shift + Tab 缩进.不缩进当前行(可选中多行) Ctrl + D 复制选定的区域 ...
- 【MAC】图片编辑工具-合成图片
MAC中和wIn环境中画图一样的工具,可以对图片进行编辑 step1: step2: step3: 从工具栏中选择你要使用的工具,进行对应的操作. step4: 合成图片: 效果如图:
- adb自动化农药金币
本贴仅为记录贴 记录adb 的环境配置及python脚本的交互 1.adb 的下载 通过搜索adb工具即可下载,这里提供一个共享地址https://pan.baidu.com/s/103ix26tZy ...
- nohup及pip命令总结
最近在搭建Python的Web开发环境的时候,用到nohup和pip等一些工具,先简单总结一下,以备后续查用. 1.nohup nohup(no hang up)就是不挂断的意思,如果你正在运行一个进 ...
- 阶段3 2.Spring_03.Spring的 IOC 和 DI_12 注入集合数据
再复制一份,改名3 常用的注入方式,这里选择set saveAccount方法输出所有的对象 map需要导包 配置xml 集合类型的值配置方式 在property标签里面再写标签 这里选择array. ...
- Series的idxmax和argmax
转载至:https://www.cnblogs.com/liulangmao/p/9211537.html pandas Series 的 argmax 方法和 idxmax 方法用于获取 Serie ...