QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282245 | #1173. Knowledge Is... | Hanghang | WA | 1ms | 7680kb | C++14 | 730b | 2023-12-11 16:45:42 | 2023-12-11 16:45:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+3;
int n,m,ans[N];
bool v[N];
struct Nod{int l,r,id;}a[N],b[N];
bool CL(Nod a,Nod b){return a.l<b.l;}
bool CR(Nod a,Nod b){return a.r<b.r;}
bool Chk(int x)
{
for(int i=1;i<=x;i++)if(a[i].r>=b[n-x+i].l)return 0;
return 1;
}
int main()
{
cin>>n>>m;int l=0,r=n/2;
for(int i=1;i<=n;i++)cin>>a[i].l>>a[i].r,a[i].id=i,b[i]=a[i];
sort(a+1,a+n+1,CR);sort(b+1,b+n+1,CL);
while(l<r)
{
int mi=(l+r)/2+1;
Chk(mi)?l=mi:r=mi-1;
}
for(int i=1;i<=min(m,l);i++)
ans[a[i].id]=ans[b[n-l+i].id]=i,v[a[i].id]=v[b[n-l+i].id]=1;
//for(int i=1;i<=n&&l<m;i++)if(!v[i])ans[i]=++l;
for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7680kb
input:
7 5 9 10 7 9 3 4 9 10 2 6 8 9 5 8
output:
2 0 1 3 2 1 3
result:
wrong answer participant answer = 6, judge answer = 7