Please read the new rule regarding the restriction on the use of AI tools. ×

2811guin's blog

By 2811guin, history, 21 month(s) ago, In English
    sort(arr.begin(), arr.end());
    int ans= 0;
    int i=0; int j=0; int sum=0;
    while(j<n){
        while( arr[j].first-arr[i].first>=k){
            sum-=arr[i].second; i++;
        }
        while(j<n && (arr[j].first-arr[i].first)<k){
            sum+=arr[j].second; j++;
            // cout<<sum<<" ";
        }cout<<endl;
        
        ans= max(ans, sum);
        // cout<<sum<<" "<<ans<<endl;
    }
   cout<<ans<<endl;
  • Vote: I like it
  • -20
  • Vote: I do not like it

| Write comment?
»
21 month(s) ago, # |
  Vote: I like it +3 Vote: I do not like it

And?

  • »
    »
    21 month(s) ago, # ^ |
    Rev. 3   Vote: I like it +6 Vote: I do not like it
    Optimistic Explanation
    Neutral (my) Interpretation
    Skeptic Interpretation