QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#439863#6433. Klee in Solitary ConfinementluqyouWA 15ms50576kbC++141.0kb2024-06-12 19:51:362024-06-12 19:51:40

Judging History

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

  • [2024-06-12 19:51:40]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:50576kb
  • [2024-06-12 19:51:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int n,k,a[maxn],res;
vector<int> pos[maxn*2];
void solve(){
	cin>>n>>k,res=0;
	for(int i=0;i<=2e6;i++) pos[i].clear();
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pos[a[i]+1000000].push_back(i);
	}
	for(int i=0;i<=2e6;i++) res=max(res,(int)pos[i].size());
//	if(k==0) return (void)(cout<<res<<endl);
//	for(int i=0;i<=2e6;i++){
//		int j=i+k,z=0;
//		if(j<0||j>2e6) continue;
//		int sz1=pos[i].size(),sz2=pos[j].size(),now=sz2;
//		if(!sz1||!sz2) continue;
////		cout<<i<<" "<<j<<endl;
//		if(z<sz2) while(z<sz2&&pos[j][z]<pos[i][0]) z++;
////		cout<<z<<" "<<pos[j][z]<<" "<<pos[i][0]<<" "<<i-1e6<<" "<<j-1e6<<endl; 
//		for(int x=0;x<sz1;x++){
//			if(z<sz2) while(z<sz2&&pos[j][z]<pos[i][x]) z++,now--;
//			res=max(res,now+x+1);
////			cout<<now<<" "<<x<<endl;
//		}
//	}
	cout<<res<<endl;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t=1;
	while(t--) solve();
	return 0;
}
/*
5 -1000000
-1000000 -1000000 3 -1000000 -1000000
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 15ms
memory: 50576kb

input:

5 2
2 2 4 4 4

output:

3

result:

wrong answer 1st numbers differ - expected: '5', found: '3'