221C

思路:

  水题;

代码:

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <iostream>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. #define maxn 200005
  9.  
  10. int n,ai[maxn],bi[maxn],ans;
  11.  
  12. inline void in(int &now)
  13. {
  14. int if_z=;now=;
  15. char Cget=getchar();
  16. while(Cget>''||Cget<'')
  17. {
  18. if(Cget=='-') if_z=-;
  19. Cget=getchar();
  20. }
  21. while(Cget>=''&&Cget<='')
  22. {
  23. now=now*+Cget-'';
  24. Cget=getchar();
  25. }
  26. now*=if_z;
  27. }
  28.  
  29. bool cmp(int a,int b)
  30. {
  31. return a<b;
  32. }
  33.  
  34. int main()
  35. {
  36. in(n);
  37. for(int i=;i<=n;i++) in(ai[i]),bi[i]=ai[i];
  38. sort(ai+,ai+n+,cmp);
  39. for(int i=;i<=n;i++) if(ai[i]!=bi[i]) ans++;
  40. if(ans<=) cout<<"YES";
  41. else cout<<"NO";
  42. return ;
  43. }

AC日记——Little Elephant and Problem codeforces 221c的更多相关文章

  1. AC日记——Little Elephant and Shifts codeforces 221e

    E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时, ...

  2. AC日记——Little Elephant and Array codeforces 221d

    221D - Little Elephant and Array 思路: 莫队: 代码: #include <cmath> #include <cstdio> #include ...

  3. AC日记——Little Elephant and Numbers codeforces 221b

    221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #inclu ...

  4. AC日记——Little Elephant and Function codeforces 221a

    A - Little Elephant and Function 思路: 水题: 代码: #include <cstdio> #include <iostream> using ...

  5. AC日记——Sagheer and Nubian Market codeforces 812c

    C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...

  6. AC日记——Red and Blue Balls codeforces 399b

    399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio&g ...

  7. AC日记——Andryusha and Colored Balloons codeforces 780c

    C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #inc ...

  8. AC日记——The Child and Sequence codeforces 250D

    D - The Child and Sequence 思路: 因为有区间取模操作所以没法用标记下传: 我们发现,当一个数小于要取模的值时就可以放弃: 凭借这个来减少更新线段树的次数: 来,上代码: # ...

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

随机推荐

  1. CentOS 7.X 防火墙简单配置

    CentOS7使用的是Linux Kernel 3.10.0的内核版本,新版的Kernel内核已经有了防火墙netfilter,并且使用效能更高,稳定性更好. 配置防火墙的两种方法: 一.使用xml配 ...

  2. 确保VDI顺利部署 试点项目是关键

    [TechTarget中国原创] 由于管理员没有全面测试虚拟桌面的性能表现导致无数VDI项目的最终失败,因此需要借助于试点项目来保证VDI部署的最终成功实施. VDI试点项目是从物理桌面向虚拟桌面迁移 ...

  3. 图解java面试

    图解Java面试题:基本语法 2017-02-07 14:34 出处:清屏网 人气:178 评论(0)   内容大纲.png &和&&的区别 &和&&的 ...

  4. Visual Studio 2017 的 JavaScript 调试功能的关闭

    关闭方法其实很简单,Options => Debugging => General => Enable JavaScript debugging for ASP.NET (Chrom ...

  5. 《Cracking the Coding Interview》——第17章:普通题——题目14

    2014-04-29 00:20 题目:给定一个长字符串,和一个词典.如果允许你将长串分割成若干个片段,可能会存在某些片段在词典里查不到,有些则查得到.请设计算法进行分词,使得查不到的片段个数最少. ...

  6. 天性 & 如水一般,遇强则强 —— 梦想、行为、性格

    开篇声明,我博客中“小心情”这一系列,全都是日记啊随笔啊什么乱七八糟的.如果一不小心点进来了,不妨直接关掉.我自己曾经写过一段时间的日记,常常翻看,毫无疑问我的文笔是很差的,而且心情也是瞬息万变的.因 ...

  7. 用js做的表单的增,删,以及全选

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>创 ...

  8. php 代码段执行时间

    <?php   //程序运行时间 $starttime = explode(' ',microtime()); echo microtime(); /*········以下是代码区······· ...

  9. lo口环路问题分析

    流程如下,collecter抓取网卡lo和wlan0数据,其中lo口无数据,wlan0是笔记本上网网口,然后按自定义协议把数据包通过lo口发给后端dispatch进行分发! 这种模式下,抓包程序每经过 ...

  10. 替换Fragment 报错 The specified child already has a parent. You must call removeView() on the child's parent first.

    在将一个fragment替换到一个frameLayout的时候报错: code: transaction.replace(R.id.fragment_container, fragment2); 错误 ...