QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607544 | #6433. Klee in Solitary Confinement | S_zhi# | WA | 468ms | 159852kb | C++14 | 914b | 2024-10-03 15:15:44 | 2024-10-03 15:15:45 |
Judging History
answer
#include <iostream>
#include <vector>
#include <map>
using namespace std ;
int solve(vector<int> q){
int final = 0 , ans = 0 , sum = 0 ;
int sz = q.size() ;
int res = 0 ;
for(int i = 0 ; i < sz ; i ++ ){
if(q[i] == 1) ans ++ , sum ++ ;
else{
if(res >= sum ) res ++ , ans = 0 ;
else ans = ans , res = 1 ;
}
final = max(final , ans + res) ;
}
return final ;
}
int main(){
map<int , vector<int> > q ;
int n , k ; cin >> n >> k ;
vector <int> a(n) ;
for(int i = 0 ; i < n ; i ++ ){
cin >> a[i] ;
q[a[i]].push_back(1) ;
q[a[i] + k].push_back(2) ;
// 1 是正主 , 2 还要转化
}
int ans = 0 ;
for(int i = -1e6 ; i <= 1e6 ; i ++ ){
ans = max(solve(q[i]) , ans) ;
}
cout << ans << endl ;
return 0 ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 426ms
memory: 159852kb
input:
5 2 2 2 4 4 4
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: -100
Wrong Answer
time: 468ms
memory: 159852kb
input:
7 1 3 2 3 2 2 2 3
output:
4
result:
wrong answer 1st numbers differ - expected: '6', found: '4'