AC日记——Little Elephant and Problem codeforces 221c
思路:
水题;
代码:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define maxn 200005 int n,ai[maxn],bi[maxn],ans; inline void in(int &now)
{
int if_z=;now=;
char Cget=getchar();
while(Cget>''||Cget<'')
{
if(Cget=='-') if_z=-;
Cget=getchar();
}
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
now*=if_z;
} bool cmp(int a,int b)
{
return a<b;
} int main()
{
in(n);
for(int i=;i<=n;i++) in(ai[i]),bi[i]=ai[i];
sort(ai+,ai+n+,cmp);
for(int i=;i<=n;i++) if(ai[i]!=bi[i]) ans++;
if(ans<=) cout<<"YES";
else cout<<"NO";
return ;
}
AC日记——Little Elephant and Problem codeforces 221c的更多相关文章
- AC日记——Little Elephant and Shifts codeforces 221e
E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时, ...
- AC日记——Little Elephant and Array codeforces 221d
221D - Little Elephant and Array 思路: 莫队: 代码: #include <cmath> #include <cstdio> #include ...
- AC日记——Little Elephant and Numbers codeforces 221b
221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #inclu ...
- AC日记——Little Elephant and Function codeforces 221a
A - Little Elephant and Function 思路: 水题: 代码: #include <cstdio> #include <iostream> using ...
- AC日记——Sagheer and Nubian Market codeforces 812c
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...
- AC日记——Red and Blue Balls codeforces 399b
399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio&g ...
- AC日记——Andryusha and Colored Balloons codeforces 780c
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #inc ...
- AC日记——The Child and Sequence codeforces 250D
D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: # ...
- Codeforces 221 C. Little Elephant and Problem
C. Little Elephant and Problem time limit per test 2 seconds memory limit per test 256 megabytes inp ...
随机推荐
- vue-cli 引入axios
写文章注册登录 首页 下载App × vue-cli 引入axios及跨域使用 星球小霸王 关注 2017.10.04 16:40* 字数 504 阅读 13038评论 2喜欢 18 使用 c ...
- X的N次方。N比较大。
final static long DIV = 1000000009; //分治法, 注意java类型为long, C++为__int64或 long long public static long ...
- 发送广播重新挂载SD卡,使图库可以及时显示自己保存的图片(无需手机重启)
我们或许经常会遇到这种情况,明明保存了图片,但是当你打开图片时,却没有找到这张图片,手机重启之后才能看到.这是因为SD卡并没有重新挂载,图库也无法把这张图片加载进去,解决这个问题非常简单,只需要我们模 ...
- 剑指Offer - 九度1506 - 求1+2+3+...+n
剑指Offer - 九度1506 - 求1+2+3+...+n2013-11-29 19:22 题目描述: 求1+2+3+...+n,要求不能使用乘除法.for.while.if.else.switc ...
- 《Cracking the Coding Interview》——第16章:线程与锁——题目2
2014-04-27 19:14 题目:如何测量上下文切换的时间? 解法:首先,上下文切换是什么,一搜就知道.对于这么一个极短的时间,要测量的话,可以通过放大N倍的方法.比如:有A和B两件事,并且经常 ...
- gradle构建
https://blog.csdn.net/baidu_30809315/article/details/77865414
- python 学习分享-socket编程
socket的英文原义是“孔”或“插座”.作为BSD UNIX的进程通信机制,取后一种意思. 通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,可以用来实现不同虚拟 ...
- Python学习-day18 Web框架
众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ...
- Python全栈工程师(装饰器、模块)
ParisGabriel 每天坚持手写 一天一篇 决定坚持几年 全栈工程师 Python人工智能从入门到精通 装饰器 decorators(专业提高篇) 装饰 ...
- UVa 1445 - Cubist Artwork
统计正面看高度为i的竖条个数为cnt1[i], 统计侧面看高度为i的竖条个数为cnt2[i]: ans = sum( i * max( cnt1[i], cnt2[i] ) ); ( 1 <= ...