2019-11-10 15:23:02

// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#define re register
using namespace std;

int X=0,w=1; char c=getchar();
while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
return X*w;
}

const int N=100000+10;

int n,m;
struct node { int l,r,k,id; } a[N],b[N];
bool operator <(node a,node b) { return a.r<b.r; }
set<pair<int,int> > S;
int ans[N];

int main() {
for (re int i=1;i<=n;++i)
for (re int i=1;i<=m;++i)
sort(a+1,a+n+1),sort(b+1,b+m+1);
for (re int i=1,p=1;i<=m;++i) {
while (p<=n&&a[p].r<=b[i].r)
S.insert(make_pair(a[p].l,a[p].id)),++p;
while (b[i].k) {
auto it=S.lower_bound(make_pair(b[i].l,0));
if (it==S.end()) break;
ans[it->second]=b[i].id,--b[i].k,S.erase(it);
}
}
for (re int i=1;i<=n;++i)
if (!ans[i]) { puts("NO"); return 0; }
puts("YES");
for (re int i=1;i<=n;++i) printf("%d%c",ans[i]," \n"[i==n]);
return 0;
}
• star
首页