当前位置:网站首页>Codeforces Round #390 (Div. 2) D. Fedor and coupons
Codeforces Round #390 (Div. 2) D. Fedor and coupons
2022-06-30 05:30:00 【不吃土司边】
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define eps 1e-2
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;
#define int long long
const int maxn = 3e5+2;
const int INF = 1<<30;
const int mod = 1e9+7;
int n,k;
int l[maxn],r[maxn];
struct node {
int l, r, id;
};
priority_queue<int> q;
bool cmp(node x,node y){
return x.l<y.l;
}
node nd[maxn];
void solve(){
scanf("%lld%lld",&n,&k);
for(int i=1;i<=n;i++) {
scanf("%lld%lld",&l[i],&r[i]);
nd[i]={
l[i],r[i],i};
}
sort(nd+1,nd+1+n,cmp);
int res=0,L=-1,R=-1;
for(int i=1;i<=n;i++){
// cout<<nd[i].l<<" "<<nd[i].r<<endl;
q.push(-nd[i].r);
if(q.size()>k) q.pop();
if(q.size()==k){
int now=(-q.top())-nd[i].l+1;
// cout<<now<<endl;
if(res<now){
res=now;
L=nd[i].l;
R=(-q.top());
}
}
}
cout<<res<<endl;
// cout<<L<<" "<<R<<endl;
if(res==0){
for(int i=1;i<=k;i++) cout<<i<<" ";cout<<endl;
}else{
for(int i=1,j=1;i<=n&&j<=k;i++){
if(nd[i].l<=L&&nd[i].r>=R){
++j;cout<<nd[i].id<<" ";
}
}cout<<endl;
}
return;
}
int32_t main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
// ios::sync_with_stdio(false);
int t = 1;
//scanf("%d",&t);
while(t--){
// printf("Case %d: ",cas++);
solve();
}
return 0;
}
边栏推荐
- 【板栗糖GIS】global mapper—如何把栅格的高程值赋予给点
- 旋转框目标检测mmrotate v0.3.1 学习配置
- 虚析构和纯虚析构
- Detailed explanation of the loss module of mmdet
- 使用码云PublicHoliday项目判断某天是否为工作日
- Visualization of 3D geological model based on borehole data by map flapping software
- Revit二次开发---未打开项目使用面板功能
- Unity publishing /build settings
- 东塔攻防世界—xss绕过安全狗
- Redistemplate common method summary
猜你喜欢

Remote sensing image /uda:curriculum style local to global adaptation for cross domain remote sensing image segmentation

Unity ugui text value suspended enlarged display add text background

Assembly learning tutorial: accessing memory (3)

Virtual and pure virtual destructions

86. 分隔链表

网络变压器怎么判断好坏?网络滤波变压器坏了一般是什么症状?

Access is denied encountered when vfpbs calls excel under IIS

Digital signature——

Unity project hosting platform plasticscm (learn to use 1)
![[notes] unity Scrollview button page turning](/img/c7/47c4056871d0212ac61524539f0d0e.jpg)
[notes] unity Scrollview button page turning
随机推荐
Unity project hosting platform plasticscm (learn to use 1)
Digital signature——
终端便捷ssh(免密)连接
Why can transformer break into the CV world and kill CNN?
Stack overflow caused by C # using protobuf stack overflow
After reading who moved my cheese
D. Big Brush
Baiwen.com 7 days Internet of things smart home learning experience punch in the third day
Shopping list--
东塔攻防世界—xss绕过安全狗
Answer sheet for online assignment of "motor and drive" of Xijiao 21 autumn (IV) [standard answer]
PyGame. Why can't I exit when I click X in the window? I can only exit when I return idle
Unity ugui text value suspended enlarged display add text background
Bev instance prediction based on monocular camera (iccv 2021)
Super comprehensive summary | related improvement codes of orb-slam2 / orb-slam3!
Remote sensing image /uda:curriculum style local to global adaptation for cross domain remote sensing image segmentation
Assembly learning tutorial: accessing memory (3)
遥感图像/UDA:Curriculum-Style Local-to-Global Adaptation for Cross-Domain Remote Sensing Image Segmentat
El table lazy load refresh
Xi'an Jiaotong 21st autumn online expansion resources of online trade and marketing (III) [standard answer]