QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607544#6433. Klee in Solitary ConfinementS_zhi#WA 468ms159852kbC++14914b2024-10-03 15:15:442024-10-03 15:15:45

Judging History

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

  • [2024-10-03 15:15:45]
  • 评测
  • 测评结果:WA
  • 用时:468ms
  • 内存:159852kb
  • [2024-10-03 15:15:44]
  • 提交

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'