2个多小时,弱智了。。(连A都做不对,就不要做D了(迷))

 #include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define LL long long
#define N 100005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int n,k;
struct node{
int x,y,id;
}a[N<<];
bool cmp(node a, node b)
{
if (a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int ans,cnt;
int b[N<<],L,R;
set<pair<int , int > > q;
set<pair<int , int > >:: iterator it;
int main()
{
n=ra(); k=ra();
for (int i=; i<=n; i++)
a[i].x=ra(),a[i].y=ra(),a[i].id=i;
sort(a+,a+n+,cmp);
if (n==)//zz
{
cout<<a[].y-a[].x+<<endl;
cout<<"";
return ;
}
// for (int i=1; i<=n; i++)
// printf("%d %d %d\n",a[i].x,a[i].y,a[i].id);
q.insert(make_pair(a[].y,a[].id));
for (int i=; i<=n; i++)
{
pair<int , int > tmp,qwq;
tmp=*q.begin();
while (a[i].x>tmp.first && !q.empty())
{
q.erase(tmp);
tmp=*q.begin();
}
q.insert(make_pair(a[i].y,a[i].id));
if (q.size()>=k)
{
tmp=*q.begin();
if (ans<tmp.first-a[i].x+)
{
cnt=;
ans=tmp.first-a[i].x+;
L=a[i].x;
R=tmp.first;
}
q.erase(tmp); //这里比较有意思,这是最小的,只要记录的最小的是没有用了的,再加着反而会让结果变小
}
}
cout<<ans<<endl;
if (ans==)
{
for (int i=; i<=k; i++) cout<<i<<" ";
}
else
{
//cout<<L<<" "<<R<<endl;
for (int i=; i<=n; i++)
if (L>=a[i].x && R<=a[i].y && k) //tmd还能这么输出,真是尴尬啊、、、
cout<<a[i].id<<" ",k--;
}
return ;
}
//%%%%%%%%%%%%%%%%cf有数据就是好,面相数据编程233

最新文章

  1. Yii2美化confirm
  2. 关于Intent ,Task, Activity的理解
  3. hdu 5366 组合数 *
  4. Android listview与adapter用法
  5. java 获取系统当前时间
  6. vim ctags 的使用
  7. 代理模式及其在spring与struts2中的体现
  8. 代码版本管理/SVN/Git
  9. Qt快速入门系列教程目录
  10. Hadoop3.0完全分布式集群安装部署
  11. hdu 5645 DZY Loves Balls
  12. ajax接收php返回得到一堆html代码
  13. Java Code Examples for org.apache.ibatis.annotations.Insert
  14. bzoj5252 [2018多省省队联测]林克卡特树
  15. RSA加解密工具类RSAUtils.java,实现公钥加密私钥解密和私钥解密公钥解密
  16. Docker 学习5 Docker容器网络
  17. Appium + Python环境搭建(移动端自动化)
  18. python模块之pickle、shelve、json
  19. Linux 中提高的 SSH 的安全性
  20. Linux版本Membase无法写入default bucket的问题分析

热门文章

  1. JAVA项目开发之文档篇
  2. [python]ubuntu下的python2和python3
  3. S32K144之FlexMem,FlexNVM,FlexRAM,System RAM, SRAM 区别与联系
  4. win32下的命令行集合 (最优秀的工具)
  5. 新闻网大数据实时分析可视化系统项目——14、Spark2.X环境准备、编译部署及运行
  6. 修剪草坪 HYSBZ - 2442
  7. golang的传值调用和传引用调用
  8. Unity内置shader 下载
  9. MyEclipse 8.5整合Git,并在Github上发布项目
  10. Python @函数装饰器及用法