题目链接

题目描述
Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He has decided to get a new wand in Olivander’s wand shop. On the floor of the shop, he saw ​N wands and ​N wand boxes. The lengths of the wands are, respectively, X_1​ ,X_2 …​X_n , and the box sizes are Y_1 ,​Y_2 …Y_n

. A wand of length ​X can be placed in a box of size ​Y if ​X ≤ ​Y . Harry wants to know if he can place all the wands in boxes so that each box contains exactly one wand. Help him solve this difficult problem.

输入格式
The first line of input contains the positive integer ​N (1 ≤ ​N ≤ 100), the number from the task. The second line contains ​N positive integers ​X_i (1 ≤ ​X_i ≤ 10^9 ​ ), the numbers from the task. The third line contains ​N positive integers ​X_i (1 ≤ X_i ≤ 10^9 ​​ ), the numbers from the task.

输出格式
If Harry can place all the wands in boxes, output “DA” (Croatian for yes), otherwise output “NE” (Croatian for no).

输入输出样例
输入 #1
3
7 9 5
6 13 10
输出 #1
DA
输入 #2
4
5 3 3 5
10 2 10 10
输出 #2
NE
输入 #3
4
5 2 3 2
3 8 3 3
输出 #3
DA
说明/提示
In test cases worth 60% of total points, it will hold ​N ≤ 9.

Clarification of the first test case:

Harry can place the wands in boxes. For example, he can place the wand of length 5 in a box of size 6, wand of length 7 in a box of size 13, and wand of length 9 in a box of size 10.

Clarification of the second test case:

Harry can’t place the wands in boxes because the box of size 2 can’t fit any of the wands.

代码:

//P4613 [COCI2017-2018#5] Olivander
#include<iostream>
#include<algorithm>
using namespace std;
int x[105] = {0}, y[105] = {0}, n, flag = 0;
int main()
{cin >> n;for(int i = 0; i < n; i++) cin >> x[i];for(int i = 0; i < n; i++) cin >> y[i];sort(x, x + n); sort(y, y + n);for(int i = 0; i < n; i++)if(y[i] < x[i]){flag = 1;cout << "NE" << endl;break;}if(flag == 0) cout << "DA" << endl;return 0;
}

[COCI2017-2018#5] Olivander相关推荐

  1. 洛谷刷题C语言:Olivander、取石子、Davor、标题统计、成绩

    记录洛谷刷题QAQ 一.[COCI2017-2018#5] Olivander 题面翻译 题意简述 有 n n n 个棍子和 n n n 个盒子,要求每个盒子里放的棍子的总长度不能超过盒子的高度.求是 ...

  2. 回顾 2018,展望 2019

    1. 概述 今天是 2019 年第一天,趁着元旦 3 天假期时间,对即将过去的这一年做个总结回顾,看下这一年得到了什么,失去了什么,并对来年做个新的规划,看下需要采取哪些措施提升自己. 2. 2018 ...

  3. 2017 年总结及 2018 年计划

    概述 本文写于 2018.01.01,计划从 2017 开始有目的的进行复盘行动,所以将该文搬运到此处. ----------------------------分界线---------------- ...

  4. 2018 Google kickstart Problem A. Planet Distance

    题目描述 Small dataset 3 ≤ N ≤ 30. Large dataset 3 ≤ N ≤ 1000.input 2 5 1 2 2 3 3 4 2 4 5 3 3 1 2 3 2 1 ...

  5. 2018年终总结:自由而独立

    时间真快,一年,走完了大三的后半学期和大四的前半学期. 这一年经历了很多事情,第一次这么久没有回家. 收获: 计算机进度: 一年的时间从VB版机房系统到现在的JS 其实,并没有很快很扎实连贯的走进度, ...

  6. VLOG丨树莓派Raspberry Pi 3安装PLEX并挂载USB硬盘打造最牛的微型家庭影音服务器2018...

    视频介绍 树莓派3安装目前最流行的PLEX服务器,实现既能最大限度降低功耗,也能随时随地观看分享影片. 一.在树莓派下安装PLEX媒体服务器 1.在终端,将你的树莓派更新至最新 sudo apt up ...

  7. 狗年拜年php源码,2018狗年拜年词大全!再也不担心拜年没祝词啦~祝您新年快乐!...

    原标题:2018狗年拜年词大全!再也不担心拜年没祝词啦~祝您新年快乐! 2018 狗 年 大 吉 HAPPY NEW YEAR 为了您在春节期间能够在第一时间 为您的亲朋好友送上祝福~ 小编已经贴心的 ...

  8. 2018usnews计算机专业排名,2018年研究生计算机专业前50排名(美USNews版)

    2018年美国大学--研究生--计算机科学专业排名: (USNews 美新闻周刊版) 排名 学校英文名  学校汉语名  州 / 城市 1 Carnegie Mellon University 卡耐基梅 ...

  9. 2018会考计算机成绩查询入口,2018年山东会考成绩查询时间及入口

    2018年山东会考成绩查询时间及入口2019-07-10 20:39:51文/李男 2018年山东会考成绩查询时间为2018年2月2日,并且山东高中会考成绩的查询入口也已经开通了,下面小编整理了会考成 ...

  10. 康复治疗学可以考计算机吗,【大揭秘】2018“人机对话”康复医学治疗技术专业技术资格考试...

    原标题:[大揭秘]2018"人机对话"康复医学治疗技术专业技术资格考试 昨天,关于"2018年康复医学治疗技术专业技术资格考试采用人机对话考试方式"的通知一经发 ...

最新文章

  1. 一步步学会使用ASP.NET 4 WEB应用程序中使用URL Routing(翻译)
  2. Shell脚步学习指南提点
  3. The “data“ option should be a function that returns a per-instance value in component definitions.
  4. Winform开发的快速、健壮、解耦的几点建议
  5. javascript 设为首页 | 加入收藏夹 JS代码
  6. KITTI Odometry数据集的GT
  7. openCV实践项目:拖拽虚拟方块
  8. 0123能组成四位数c语言,用0123四个数字能组成多少个不同的三位数
  9. UVA - 10827 Maximum sum on a torus
  10. python判断某一天是一年中的第几天
  11. arm架构linux系统平板电脑推荐,x86平板电脑排行_X86平板电脑推荐成垃圾,ARM架构平板电脑品牌是王道...
  12. Python爬虫三:抓取链家已成交二手房信息(58W数据)
  13. (趣文)我是一个线程
  14. 简简的语法3:对句子按用途进行划分
  15. html5绘制矩形动画,HTML5 Canvas中绘制矩形实例
  16. IVM import vector machine
  17. vue2+element-ui创建顶部导航栏及下拉菜单
  18. Ubuntu apt安装包 dev、dbg、utils后缀的含义
  19. Cypher查询语言--Neo4j中的SQL
  20. 可复现的 PyTorch

热门文章

  1. 微信小程序——数据传递(子传父)
  2. 1到10的阶乘 java_java里1到10的阶乘相加编程怎么做?
  3. 用C语言计算1到20的阶乘之和,用C语言计算1~20的阶乘之和
  4. 浩辰软件IPO过会:年营收2.4亿拟募资7.5亿 红杉是股东
  5. 【知识星球】图像生成玩腻了?视频生成技术何不来了解一下
  6. LibUsbDotNet2.2.29版本通过usb口,获取扫码盒子扫码数据,读取数据不全和不对
  7. 学习嵌入式如何越挫越勇?
  8. linux 外部内核模块设定 CFLAGS
  9. 微软将在 6 月 24 日的活动中推出重新设计的 Windows 10
  10. EZ28环氧云铁中间漆