ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213975 | #2400. 椅子 | nullptr_qwq | 100 | 1320ms | 9136kb | C++11 | 5.8kb | 2024-11-14 20:46:18 | 2024-11-14 23:06:29 |
answer
// 私は猫です
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
ll read(){
ll x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
return x*f;
}
namespace Fastio{struct Reader{template<typename T>Reader&operator>>(T&x){x=0;short f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();x*=f;return*this;}Reader&operator>>(double&x){x=0;double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(long double&x){x=0;long double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(__float128&x){x=0;__float128 t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(char&c){c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();return*this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(string&str){str.clear();char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{const int Setprecision=6;typedef int mxdouble;template<typename T>Writer&operator<<(T x){if(x==0){putchar('0');return*this;}if(x<0)putchar('-'),x=-x;static short sta[40];short top=0;while(x>0)sta[++top]=x%10,x/=10;while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(long double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(long double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(__float128 x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(__float128)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(char c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}using namespace Fastio;
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int mod=998244353,maxn=500005;
namespace seg{
#define ls (o<<1)
#define rs (o<<1|1)
int t[maxn<<2],tag[maxn<<2];
void clear(){ memset(t,0,sizeof t),memset(tag,0,sizeof tag); }
void build(int o,int l,int r){
t[o]=r;
if(l==r)return;
int mid=(l+r)>>1; build(ls,l,mid),build(rs,mid+1,r);
}
inline void maketag(int o,int val){ tag[o]+=val,t[o]+=val; }
inline void pushdown(int o){ if(tag[o])maketag(ls,tag[o]),maketag(rs,tag[o]),tag[o]=0; }
void update(int o,int l,int r,int ql,int qr,int val){
if(ql<=l&&qr>=r)return maketag(o,val),void();
int mid=(l+r)>>1; pushdown(o);
if(ql<=mid)update(ls,l,mid,ql,qr,val);
if(qr>mid)update(rs,mid+1,r,ql,qr,val);
t[o]=max(t[ls],t[rs]);
}
int query(int o,int l,int r,int ql,int qr){
if(ql<=l&&qr>=r)return t[o];
int mid=(l+r)>>1,res=0; pushdown(o);
if(ql<=mid)res=query(ls,l,mid,ql,qr);
if(qr>mid)chkmax(res,query(rs,mid+1,r,ql,qr));
return res;
}
}
int n,m;
pii a[maxn];
void solve(){
cin>>n>>m;
F(i,1,n)cin>>a[i].fi>>a[i].se;
sort(a+1,a+n+1);
int ans=max(0,n-m);
seg::build(1,1,m+1);
F(i,1,n)seg::update(1,1,m+1,a[i].fi,a[i].se,1),chkmax(ans,seg::query(1,1,m+1,a[i].fi+1,m+1)-m-1-a[i].fi);
cout<<ans;
}
signed main(){
// ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int zsy=1;
F(____,1,zsy)solve();
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 5036kb
input:
8 8 1 8 1 5 2 8 0 5 0 3 2 6 2 6 2 6
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 3ms
memory: 5036kb
input:
10 10 0 5 2 9 3 10 2 7 1 6 0 10 0 9 2 10 0 9 1 10
output:
2
result:
ok single line: '2'
Test #3:
score: 5
Accepted
time: 3ms
memory: 5040kb
input:
20 20 4 16 2 11 3 19 6 12 7 18 1 14 4 10 5 20 6 14 8 17 1 12 2 11 7 18 7 15 0 15 1 12 2 19 7 13 4 10...
output:
1
result:
ok single line: '1'
Test #4:
score: 5
Accepted
time: 0ms
memory: 5044kb
input:
96 93 2 67 5 61 4 74 15 68 3 63 40 91 14 58 6 66 9 57 18 85 13 63 40 85 17 89 16 73 10 72 15 74 15 6...
output:
7
result:
ok single line: '7'
Test #5:
score: 5
Accepted
time: 3ms
memory: 5040kb
input:
100 100 29 70 17 68 25 77 13 74 9 79 42 90 34 99 18 100 3 80 21 71 26 63 6 54 43 89 41 78 19 78 13 9...
output:
2
result:
ok single line: '2'
Test #6:
score: 5
Accepted
time: 4ms
memory: 5052kb
input:
952 954 182 871 114 769 110 694 91 741 22 509 53 841 124 858 16 465 160 789 24 720 96 939 56 689 313...
output:
64
result:
ok single line: '64'
Test #7:
score: 5
Accepted
time: 4ms
memory: 5052kb
input:
1000 1000 74 795 175 641 39 618 19 971 162 873 93 731 480 989 357 932 4 693 266 965 89 581 47 560 27...
output:
74
result:
ok single line: '74'
Test #8:
score: 5
Accepted
time: 3ms
memory: 5168kb
input:
4516 4690 665 4024 1062 3765 1573 4200 1035 4155 441 2678 31 3472 87 3450 146 2286 310 4267 1231 450...
output:
69
result:
ok single line: '69'
Test #9:
score: 5
Accepted
time: 7ms
memory: 5168kb
input:
5000 5000 62 4476 1146 3647 531 4569 1042 3464 2044 4817 2186 4584 2223 4892 1224 4761 1154 4943 147...
output:
250
result:
ok single line: '250'
Test #10:
score: 5
Accepted
time: 11ms
memory: 5164kb
input:
10000 5000 1106 4454 1138 4746 926 4805 609 4507 259 4543 1435 4211 790 3399 528 3426 38 4665 87 404...
output:
5347
result:
ok single line: '5347'
Test #11:
score: 5
Accepted
time: 12ms
memory: 5292kb
input:
10000 10000 2224 8599 3697 9779 1264 7760 266 8474 601 9386 5276 9907 4231 9619 2206 8589 3306 9731 ...
output:
574
result:
ok single line: '574'
Test #12:
score: 5
Accepted
time: 46ms
memory: 6900kb
input:
93875 99655 0 25859 0 30798 0 89053 0 29230 0 93483 0 83280 0 47502 0 39669 0 69861 0 64184 0 35067 ...
output:
14154
result:
ok single line: '14154'
Test #13:
score: 5
Accepted
time: 52ms
memory: 6860kb
input:
100000 100000 0 50602 0 56129 0 65965 0 75241 0 71832 0 26413 0 79671 0 73842 0 78772 0 94149 0 3483...
output:
25000
result:
ok single line: '25000'
Test #14:
score: 5
Accepted
time: 96ms
memory: 7084kb
input:
91057 96847 21419 89318 2406 89095 2941 51033 14888 77083 28023 74840 18260 62296 6297 51346 7735 88...
output:
134
result:
ok single line: '134'
Test #15:
score: 5
Accepted
time: 97ms
memory: 7088kb
input:
100000 100000 16723 78322 7205 66894 9839 72285 7661 85725 38680 93140 6182 88375 30785 99006 38538 ...
output:
5118
result:
ok single line: '5118'
Test #16:
score: 5
Accepted
time: 228ms
memory: 9132kb
input:
198495 197435 63738 165927 17757 117506 9207 170263 50748 141346 18132 120887 49285 188664 25304 190...
output:
11098
result:
ok single line: '11098'
Test #17:
score: 5
Accepted
time: 223ms
memory: 9136kb
input:
199260 192470 22818 156104 9228 171776 43025 139453 39938 135662 18272 171006 68109 171295 28220 116...
output:
15568
result:
ok single line: '15568'
Test #18:
score: 5
Accepted
time: 156ms
memory: 9136kb
input:
200000 200000 75002 167675 8656 181873 54606 156991 48075 167451 74414 194621 55633 180796 4565 1657...
output:
10484
result:
ok single line: '10484'
Test #19:
score: 5
Accepted
time: 141ms
memory: 9136kb
input:
200000 200000 59298 170956 2760 194028 35447 153792 1945 163425 73195 176225 62065 185526 85886 1916...
output:
10543
result:
ok single line: '10543'
Test #20:
score: 5
Accepted
time: 231ms
memory: 9136kb
input:
200000 200000 67496 171474 36806 170296 86759 193181 7951 171117 85324 184470 8949 171983 10465 1547...
output:
10575
result:
ok single line: '10575'
Extra Test:
score: 0
Extra Test Passed