QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642626#6433. Klee in Solitary Confinementwzxtsl#TL 0ms0kbC++23631b2024-10-15 15:22:262024-10-15 15:22:27

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 15:22:27]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-15 15:22:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define For(i,aa,ac) for(int i=aa;i<=ac;i++)
int n,a,k;
const int N=1e6+7;
map<int,int> mp,mp1,now;
void solve(){
	cin>>n>>k;
    For(i,1,n)
    {
        cin>>a;
        mp[a]++;
        if((a+k<=1000000)&&(a+k>=-1000000)) now[a+k]++,mp1[a+k]=max(mp1[a+k],now[a+k]);
        if(now[a]>0) now[a]--;
    }
    int ans=0;
    For(i,-1000000,1000000)
        ans=max(ans,mp[i]+mp1[i]);
    cout<<ans;
}
signed main(){
	fast;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

5 2
2 2 4 4 4

output:


result: