LeetCode Weekly Contest 183 1問目 - Minimum Subsequence in Non-Increasing Order [1403]

Source

LeetCode Weekly Contest 183
問題文

問題概要

省略

解法

省略

cLayversion 20200408-1)のコード

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

#define main dummy_main
{}
#undef main

class Solution {
public:
  vector<int> minSubsequence(vector<int>& A) {
    int tot, now = 0, N = A.size();
    vector<int> res;
    sort(A.begin(), A.end());

    tot = sum(A(N));
    rrep(i,N) if(now <= tot){
      res.push_back(A[i]);
      now += A[i];
      tot -= A[i];
    }

    return res;
  }
};

Current time: 2024年05月08日23時53分37秒
Last modified: 2020年04月10日06時28分21秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: