A 暴力查询,分三段查就可以了

#include<bits/stdc++.h>
using namespace std;
const int N = ;
int n, pos;
int a[N];
int main()
{
scanf("%d", &n);
for(int i = ; i <= n; ++i) scanf("%d", &a[i]);
pos = -;
for(int i = ; i <= n; ++i) if(a[i] - a[i - ] <= )
{
pos = i;
break;
}
if(pos == -)
{
puts("YES");
return ;
}
for(int i = pos; i <= n; ++i)
{
pos = ;
if(a[i] - a[i - ] > )
{
puts("NO");
return ;
}
else if(a[i] - a[i - ] < )
{
pos = i;
break;
}
}
if(!pos)
{
puts("YES");
return ;
}
for(int i = pos; i <= n; ++i)
{
if(a[i] - a[i - ] >= )
{
puts("NO");
return ;
}
}
puts("YES");
return ;
}

B 开个数组映射一下

#include<bits/stdc++.h>
using namespace std;
const int N = ;
int n;
char s1[N], s2[N], s[N];
int Map[N];
int main()
{
scanf("%s%s%s", s1 + , s2 + , s + );
n = strlen(s1 + );
for(int i = ; i <= n; ++i) Map[s1[i] - 'a'] = s2[i] - 'a';
for(int i = ; i <= strlen(s + ); ++i)
{
if(isdigit(s[i]))
printf("%c", s[i]);
if(islower(s[i]))
printf("%c", (char)(Map[s[i] - 'a'] + 'a'));
if(isupper(s[i]))
printf("%c", (char)(Map[s[i] - 'A'] + 'A'));
}
return ;
}

C 没想出来,这种题目发现用b在a上算不行就应该转换用a在b上算。统计每个b对于每个a产生的初始值,如果一个初始值出现了k次,那么就是可以的。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
ll tot;
int n, k, ans;
ll a[N];
map<ll, int> mp;
vector<ll> v;
inline int read()
{
int x = , f = ; char c = getchar();
while(c < '' || c > '') { if(c == '-') f = -; c = getchar(); }
while(c >= '' && c <= '') { x = x * + c - ''; c = getchar(); }
return x * f;
}
int main()
{
scanf("%d%d", &n, &k);
for(int i = ; i <= n; ++i)
{
a[i] = read() + a[i - ];
v.push_back(a[i]);
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for(register int i = ; i <= k; ++i)
{
int x;
x = read();
for(int j = ; j < v.size(); ++j)
++mp[x - v[j]];
}
for(map<ll, int> :: iterator it = mp.begin(); it != mp.end(); ++it)
ans += (it -> second == k);
printf("%d\n", ans);
return ;
}

D dp,dp[i][j]表示第i个人选到第j个钥匙,dp[i][j]=min(dp[i][j-1],max(dp[i-1][j-1],abs(a[i]-b[j])+(b[j]-p))就好了

看错题目+C题 这道题1小时35分才出来。。。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
int n, k, p;
int a[N], b[N];
ll dp[N][N];
int main()
{
scanf("%d%d%d", &n, &k, &p);
for(int i = ; i <= n; ++i) scanf("%d", &a[i]);
for(int i = ; i <= k; ++i) scanf("%d", &b[i]);
sort(a + , a + n + );
sort(b + , b + k + );
for(int i = ; i <= n; ++i) dp[i][]= 1e16;
for(int i = ; i <= n; ++i)
for(int j = ; j <= k; ++j)
dp[i][j] = min(dp[i][j - ], max(dp[i - ][j - ], (ll)abs(a[i] - b[j]) + (ll)abs(b[j] - p)));
ll ans = 1e16;
for(int i = n; i <= k; ++i)
ans = min(ans, dp[n][i]);
printf("%lld\n", ans);
return ;
}

E 平衡树练习题 其实很简单就能搞定。我们发现如果选了一轮序列就会恢复原来的样子,只是删除了一些数。那么我们开set记录每个数出现的位置,从最小的数开始枚举,如果没到结尾加上上次到这次的距离,否则回到开头,因为每个数只删除一次,我们用size记录需要加上的答案,每删除一次size减1,到了一轮结束加上size。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
int n, sz;
ll ans;
int a[N], tree[N];
set<int> s[N];
int main()
{
scanf("%d", &n);
for(int i = ; i <= n; ++i)
{
scanf("%d", &a[i]);
s[a[i]].insert(i);
}
sort(a + , a + n + );
int last = ;
ans = n;
sz = n;
for(int i = ; i <= n; ++i)
{
set<int> :: iterator it = s[a[i]].lower_bound(last);
if(it == s[a[i]].end())
{
ans += sz;
it = s[a[i]].begin();
}
last = *it;
--sz;
s[a[i]].erase(it);
}
printf("%lld\n", ans);
return ;
}

codeforces round #424 div2的更多相关文章

  1. Codeforces Round #424 Div2 E. Cards Sorting

    我只能说真的看不懂题解的做法 我的做法就是线段树维护,毕竟每个数的顺序不变嘛 那么单点维护 区间剩余卡片和最小值 每次知道最小值之后,怎么知道需要修改的位置呢 直接从每种数维护的set找到现在需要修改 ...

  2. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  3. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  4. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  5. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  6. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  7. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  8. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  9. Codeforces Round #359 div2

    Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...

随机推荐

  1. python web 开发学习路线

    转载,备着 自己目前学习python web 开发, 经过两个月的摸索,目前对web开发有了浅显的认识,把自己的学习过程贴出来.1.python入门推荐老齐<从零开始学python>,&l ...

  2. ARM处理器的寄存器,ARM与Thumb状态,7中运行模式

     ** ARM处理器的寄存器,ARM与Thumb状态,7中运行模式  分类: 嵌入式 ARM处理器工作模式一共有 7 种 : USR  模式    正常用户模式,程序正常执行模式 FIQ模式(Fast ...

  3. C# Winform 最大化后 任务栏还显示解决

    //最大化 this.WindowState = FormWindowState.Maximized; //窗体最大化时 非全屏 不会遮盖任务栏 //去掉标题栏 this.FormBorderStyl ...

  4. Linux 通过cksum 来判断文件是否是相同

    1. 最近scp部署文件时 发现日期会发生变化 (刚查了下 可以使用 -p 命令进行处理) 会变成部署时的日期. 不好判断文件倒是有没有部署 2. 最简单的办法 我mount了 补丁服务器  到lin ...

  5. Ubuntu 常用解压与压缩命令

    参考 https://blog.csdn.net/songbinxu/article/details/80435665 示例: 把/home/wangju/gitlab/automationTest目 ...

  6. plsql developer连接oracle数据库

    1.下载安装PLSQL Developer12 访问PLSQL Developer官网https://www.allroundautomations.com/bodyplsqldevreg.html, ...

  7. API 接口监控产品全新改版,免费开放全部功能

    作为 EOLINKER 研发管理体系的重要一环,EOLINKER 接口监控即 AMT 产品将在 3月4日 迎来全新变化,AMT 产品将正式命名为 EOLINKER-API Beacon --API-烽 ...

  8. Day 13 进程和线程

    进程和线程 今天我们使用的计算机早已进入多CPU或多核时代,而我们使用的操作系统都是支持“多任务”的操作系统,这使得我们可以同时运行多个程序,也可以将一个程序分解为若干个相对独立的子任务,让多个子任务 ...

  9. c/c++排坑(5) -- c语言中的申明

    C语言的申明总是令人头大,对于这块内容也一直让我头疼.希望通过这篇博客能够稍微梳理一下.材料和例子来源于<C专家编程> 一.C语言的申明的优先级规则 先来个例子,看看下面这行C代码到底是个 ...

  10. Sort HDU5884(二分+多叉哈夫曼树)

    HDU5884 Sort 题意:有n个序列要进行归并,每次归并的代价是两个序列的长度的和,要求最终的代价不能超过规定的T,求在此前提下一次能同时进行归并的序列的个数k. 思路:还是太单纯,看完题目一直 ...