Submission #3019749
Source Code Expand
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<queue> #define LL long long #define M 200200 #define mid (l+r>>1) using namespace std; int read(){ int nm=0,fh=1;char cw=getchar(); for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh; for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0'); return nm*fh; } int n,m,ans,f[M],cnt,vis[M],last; int fd(int x){return x==f[x]?x:f[x]=fd(f[x]);} struct op{ int L,R,id; void gtin(int x){L=read(),R=read(),id=x;} bool operator <(const op&ot)const{return R==ot.R?L>ot.L:R>ot.R;} }t[M]; bool cmpL(op i,op j){return i.L<j.L;} bool cmpR(op i,op j){return i.R<j.R;} priority_queue<op> Q; void del(int x,int maxn){ x=fd(x); if(x<=maxn) f[x]=fd(x+1); else ans++; } int main(){ n=read(),m=read(),f[0]=0,f[m+1]=m+1; for(int i=1;i<=n;i++) t[i].gtin(i); sort(t+1,t+n+1,cmpL),last=1; for(int i=1;i<=n;i++){ if(last<=t[i].L){last++,Q.push(t[i]);continue;} Q.push(t[i]); Q.pop(); } for(int i=1;i<=m;i++) f[i]=i; while(!Q.empty()) vis[Q.top().id]=1,Q.pop(); for(int i=1;i<=n;i++) if(vis[t[i].id]) del(1,t[i].L); sort(t+1,t+n+1,cmpR); for(int i=1;i<=n;i++) if(!vis[t[i].id]) del(t[i].R,m); printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Exhausted? |
User | luogu_bot3 |
Language | C++ (GCC 5.4.1) |
Score | 1000 |
Code Size | 1304 Byte |
Status | AC |
Exec Time | 101 ms |
Memory | 9072 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 87 ms | 6772 KB |
02.txt | AC | 56 ms | 6004 KB |
03.txt | AC | 101 ms | 8432 KB |
04.txt | AC | 100 ms | 8944 KB |
05.txt | AC | 4 ms | 896 KB |
06.txt | AC | 70 ms | 6388 KB |
07.txt | AC | 89 ms | 5496 KB |
08.txt | AC | 100 ms | 9072 KB |
09.txt | AC | 89 ms | 6004 KB |
10.txt | AC | 24 ms | 2552 KB |
11.txt | AC | 64 ms | 4096 KB |
12.txt | AC | 47 ms | 3328 KB |
13.txt | AC | 62 ms | 3456 KB |
14.txt | AC | 62 ms | 3456 KB |
15.txt | AC | 64 ms | 4224 KB |
16.txt | AC | 46 ms | 3320 KB |
17.txt | AC | 81 ms | 5492 KB |
18.txt | AC | 81 ms | 5492 KB |
19.txt | AC | 77 ms | 4980 KB |
20.txt | AC | 89 ms | 6388 KB |
21.txt | AC | 16 ms | 2044 KB |
22.txt | AC | 81 ms | 5492 KB |
23.txt | AC | 12 ms | 1344 KB |
24.txt | AC | 84 ms | 5492 KB |
25.txt | AC | 24 ms | 2816 KB |
26.txt | AC | 22 ms | 2176 KB |
27.txt | AC | 24 ms | 3200 KB |
28.txt | AC | 25 ms | 3072 KB |
29.txt | AC | 65 ms | 6640 KB |
30.txt | AC | 65 ms | 6640 KB |
31.txt | AC | 83 ms | 5492 KB |
32.txt | AC | 75 ms | 4852 KB |
33.txt | AC | 93 ms | 5492 KB |
34.txt | AC | 53 ms | 3832 KB |
35.txt | AC | 40 ms | 3320 KB |
36.txt | AC | 83 ms | 6132 KB |
37.txt | AC | 1 ms | 256 KB |
38.txt | AC | 1 ms | 256 KB |
39.txt | AC | 1 ms | 256 KB |
40.txt | AC | 1 ms | 256 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 2 ms | 1024 KB |
44.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |
s4.txt | AC | 1 ms | 256 KB |