码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • B. Increasing


    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    You are given an array aa of nn positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that a1

    Input

    The first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of test cases.

    The first line of each test case contains a single integer nn (1≤n≤1001≤n≤100) — the length of the array.

    The second line of each test case contains nn integers aiai (1≤ai≤1091≤ai≤109) — the elements of the array.

    Output

    For each test case, output "YES" (without quotes) if the array satisfies the condition, and "NO" (without quotes) otherwise.

    You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

    Example

    input

    Copy

     
    

    3

    4

    1 1 1 1

    5

    8 7 1 3 4

    1

    5

    output

    Copy

    NO
    YES
    YES
    

    Note

    In the first test case any rearrangement will keep the array [1,1,1,1][1,1,1,1], which is not strictly increasing.

    In the second test case, you can make the array [1,3,4,7,8][1,3,4,7,8].

    解题说明:水题,只需要判断不出现相同的数字即可。

    1. #include
    2. int a[1000];
    3. int main()
    4. {
    5. int b, c, N, n, i, j, k, flag = 1;
    6. scanf("%d", &N);
    7. for (i = 0; i < N; i++)
    8. {
    9. flag = 1;
    10. scanf("%d", &n);
    11. for (j = 0; j < n; j++)
    12. {
    13. scanf("%d", &a[j]);
    14. for (k = 0; k < j; k++)
    15. {
    16. if (a[k] == a[j])
    17. {
    18. flag = 0;
    19. }
    20. }
    21. }
    22. if (flag == 1)
    23. {
    24. printf("YES\n");
    25. }
    26. else
    27. {
    28. printf("NO\n");
    29. }
    30. }
    31. return 0;
    32. }

  • 相关阅读:
    MySQL高级学习八
    新零售SaaS架构:订单履约系统架构设计(万字图文总结)
    使用kubesphere图形界面创建一个应用操作流程
    阿里云服务器全方位介绍——看这一篇就够了
    创建型模式-单例模式
    基于springboot的家政系统毕业设计源码201524
    魔法的尽头是科技——用Python将普通视频变成动漫视频
    中级JAVA程序员应该掌握的数据结构知识
    【Java 进阶篇】JDBC ResultSet 类详解
    从MVC到DDD,该如何下手重构?
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/127723331
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号