zoukankan      html  css  js  c++  java
  • 【洛谷 4613】Olivander

    题目描述

    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_1X1 ,X_2X2 ...​X_nXn , and the box sizes are Y_1Y1,​Y_2Y2 ...Y_nYn . 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_iXi (1 ≤ ​X_iXi ≤ 10^9109​ ), the numbers from the task. The third line contains ​N positive integers ​X_iXi (1 ≤ X_iXi ≤ 10^9109​​ ), 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.

    题解:一难配一简单哈哈。红题快乐。

    #include<cstdio>
    #include<iostream>
    #include<cmath>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #include<queue>
    #include<bits/stdc++.h>
    using namespace std;
    const int N=20;
    int n,a[N],b[N];
    bool ycll(){
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)
            scanf("%d",&b[i]);   
        sort(a+1,a+n+1);
        sort(b+1,b+n+1);
        for(int i=1;i<=n;i++)
            if(b[i]<a[i]) return 0;
        return 1;
    }
    
    int main(){
        freopen("4613.in","r",stdin);
        freopen("4613.out","w",stdout);
        int pp=ycll();
        if(pp==1) puts("DA");
        else puts("NE");
        return 0;
    }
  • 相关阅读:
    一道打印的面试题
    Quartz使用总结
    子类和父类之间的静态代码块、静态方法、非静态代码块、构造函数之间的执行关系
    springboot使用 @EnableScheduling、@Scheduled开启定时任务
    springboot的Interceptor、Filter、Listener及注册
    ConcurrentHashMap 的工作原理及代码实现
    为什么Hashtable ConcurrentHashmap不支持key或者value为null
    Android 通过Java代码生成创建界面。动态生成View,动态设置View属性。addRules详解
    Android 自定义title 之Action Bar
    Android常用控件之GridView与ExpandableListView的用法
  • 原文地址:https://www.cnblogs.com/wuhu-JJJ/p/11857405.html
Copyright © 2011-2022 走看看