IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发测试 -> B. Moamen and k-subarrays -> 正文阅读

[开发测试]B. Moamen and k-subarrays

B. Moamen and k-subarrays

B.莫阿门和k-子阵

time limit per test: 2 seconds
每次测试的时间限制:2秒

memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节

input: standard input
输入:标准输入

output: standard output
产出:标准产出

Moamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the fllwing operations in order
莫阿门有一个n个不同整数的数组。他希望通过按顺序执行fllwing操作,按非递减顺序对数组进行排序。

exactly once:
准确地说是一次:

  1. Split the array into exactly k non-empty subarrays such that each element belongs to exactly one subarray.
    1.将数组拆分为完全k个非空子数组,使每个元素恰好属于一个子数组。

  2. Reorder these subarrays arbitrary.
    2.任意重新排序这些子数组。

  3. Merge the subarrays in their new order.
    3.将子数组按新顺序合并。

A sequence a is a subarray of a sequence b if a can be obtained from b by deletion of several (possibly, zero or all) elements from the
序列a是序列b的子数组,如果可以从b中删除几个(可能是零或全部)元素来获得a。

beginning and several (possibly, zero or all) elements from the end.
开始和从末尾开始的几个(可能是零或全部)元素。

Can you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?
你能告诉莫阿门,如果有一种方法来排序数组的非递减顺序使用上面写的操作?

Input
输入

The first line contains a single integert(1 < t < 103)- the number of test cases. The description of the test cases fllws.
第一行包含一个整数(1<t<103)–测试用例的数量。测试用例的描述。

The first line of each test case contains two integers nandk(1≤k≤n≤105).
每个测试用例的第一行包含两个整数nandk(1≤k≤n≤105)。

The second line contains n integers a1, a…,an(0≤|a|≤10"). It is guaranteed that all numbers are distinct.
第二行包含n个整数A1,a.,a,≤,≤10“,保证所有数字都是不同的。

It is guaranteed that the sum of n over all test cases does not exceed 3.105.
保证所有测试用例上n的和不超过3.105。

模拟
看有多少组符合顺序即可


int a[100007],b[100007];
map<ll ,ll>book;
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
    ll n,m;
     ll sum=0;
      cin>>n>>m;
        for (int i = 0; i < n; ++i) {
            cin>>a[i];
          b[i]=a[i];
        }
        sort(b,b+n);
        for (int i = 0; i < n-1; ++i) {
            book[b[i]]=b[i+1];
        }
        book[b[n-1]]=-1e10;
        for (int i = 0; i < n; ++i) {
            sum++;
            while(a[i+1]==book[a[i]])
            {
                ++i;
            }
        }
        //cout<<sum<<endl;///
        if(sum<=m)
            cout<<"Yes"<<endl;
        else
            cout<<"No\n";
        }
 
    return 0;
}
  开发测试 最新文章
pytest系列——allure之生成测试报告(Wind
某大厂软件测试岗一面笔试题+二面问答题面试
iperf 学习笔记
关于Python中使用selenium八大定位方法
【软件测试】为什么提升不了?8年测试总结再
软件测试复习
PHP笔记-Smarty模板引擎的使用
C++Test使用入门
【Java】单元测试
Net core 3.x 获取客户端地址
上一篇文章      下一篇文章      查看所有文章
加:2021-08-13 12:34:55  更:2021-08-13 12:35:52 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年10日历 -2024/10/18 16:30:53-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码