QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#723140 | #6433. Klee in Solitary Confinement | ONISINO | WA | 2ms | 11060kb | C++20 | 1.8kb | 2024-11-07 21:15:40 | 2024-11-07 21:15:40 |
Judging History
answer
#include <bits/stdc++.h>
//DEBUG: https://github.com/sharkdp/dbg-macro
#ifdef LOCAL
#include "../Lib/dbg-macro-0.5.1/dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
#define endl '\n'
using namespace std;
typedef long long ll;
typedef long double llf;
const ll MAXN=2e5+10,MOD=998244353,INF=1e9;
ll qpow(ll base,ll exp){ll ans=1;while(exp){if(exp&1)(ans*=base)%=MOD;(base*=base)%=MOD;exp>>=1;}return ans;}
template<class T>ll max_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r+1)/2;if(cmp^!check(m))l=m;else r=m-1;}return l;}
template<class T>ll min_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r)/2;if(cmp^!check(m))r=m;else l=m+1;}return r;}
ll exgcd(ll a,ll b,ll &x,ll &y){ll tmp;return b==0?(x=1,y=0,a):(tmp=exgcd(b,a%b,y,x),y-=(a/b)*x,tmp);}
ll highbit(ll x){for(ll i=1;i<(ll)sizeof(ll)*4;i<<=1)x|=x>>i;return x-(x>>1);}
ll lowbit(ll x){return x&(-x);}
//--------Global declared area--------
//--------Global declared end --------
void solve(int test_num){
int n,k,tmp,ans=0;
cin>>n>>k;
map<int,vector<int>> m;
vector<int> cnt(2e6+5);
for(int i=0;i<n;i++){
cin>>tmp;
tmp+=1e6;
m[tmp].push_back(-1);
m[tmp+k].push_back(1);
cnt[tmp]++;
ans=max(ans,cnt[tmp]);
}
if(k!=0){
for(auto [x,a]:m){
int sum=0,c=cnt[x];
for(int i=0;i<(int)a.size();i++){
if(sum>0){
sum+=a[i];
}else{
sum=a[i];
}
ans=max(ans,c+sum);
}
}
}
cout<<ans<<endl;
}
int main(){
#ifdef ACM
freopen("D:/Code/C or C++/File/input.txt","r",stdin);
freopen("D:/Code/C or C++/File/output.txt","w",stdout);
freopen("D:/Code/C or C++/File/error.txt","w",stderr);
#else
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr),std::cout.tie(nullptr);
#endif
int t=1;
// cin>>t;
for(int i=1;i<=t;i++){
solve(i);
//cout.flush();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 11060kb
input:
5 2 2 2 4 4 4
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 11036kb
input:
7 1 3 2 3 2 2 2 3
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 2ms
memory: 10916kb
input:
7 1 2 3 2 3 2 3 3
output:
5
result:
ok 1 number(s): "5"
Test #4:
score: 0
Accepted
time: 2ms
memory: 11036kb
input:
9 -100 -1 -2 1 2 -1 -2 1 -2 1
output:
3
result:
ok 1 number(s): "3"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 11056kb
input:
200 121649 0 527189 -1000000 -306471 -998939 527189 -1000000 -1000000 0 527189 0 527189 0 527189 -306471 -998939 -306471 -306471 -306471 0 0 527189 527189 1000000 527189 -1000000 1000000 648838 -1000000 -998939 -998939 -998939 0 1000000 -1000000 -998939 527189 1000000 648838 -1000000 1000000 648838 ...
output:
1209017455
result:
wrong answer 1st numbers differ - expected: '37', found: '1209017455'