QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218852 | #6433. Klee in Solitary Confinement | kokomiisbest | WA | 1ms | 3408kb | C++14 | 605b | 2023-10-18 19:20:06 | 2023-10-18 19:20:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,k;
const int N = 1e6+10;
int a[N];
int main(){
cin>>n>>k;
unordered_map<int,int> ump,ump1;
for(int i=1;i<=n;i++){
int x;
cin>>x;
a[i]=x;
ump[x]++;
}
int cf=a[0];
int cnt=1;
for(int i=2;i<=n;i++){
if(a[i]==a[i-1]){
cnt++;
}else{
ump1[cf+k]=max(ump1[cf+k],cnt);
cf=a[i];
cnt=1;
}
}
int max1=0;
for(auto x:ump){
max1=max(max1,x.second+ump1[x.first]);
}
// cout<<ump[3]<<ump1[3]<<endl;
cout<<max1;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3408kb
input:
5 2 2 2 4 4 4
output:
4
result:
wrong answer 1st numbers differ - expected: '5', found: '4'