QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#642626 | #6433. Klee in Solitary Confinement | wzxtsl# | TL | 0ms | 0kb | C++23 | 631b | 2024-10-15 15:22:26 | 2024-10-15 15:22:27 |
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
5 2 2 2 4 4 4