LeetCode Weekly Contest 288 3問目 - Maximum Product After K Increments [2233]

Source

LeetCode Weekly Contest 288
問題文

問題概要

省略

解法

省略

cLay(version 20220312-1)のコード

C++に変換後のコードはこちら

#define main dummy_main
{}
#undef main

class Solution {
public:
  int maximumProduct(VI& A, int K) {
    int x, N = A.size();
    x = bsearch_max[ll,x,0,1d7](sum[i,0,N](max(x-A[i],0)) <= K);
    rep(i,N) (A[i], K) += (1, -1) * max(x-A[i], 0);
    rep(i,N) if(A[i]==x && K > 0) A[i]++, K--;
    return mul[Modint][i,0,N](A[i]);
  }
};

Current time: 2024年05月19日07時46分08秒
Last modified: 2022年04月10日17時42分17秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: