LeetCode Biweekly Contest 4 4問目 - Divide Array Into Increasing Sequences [1121]

Source

LeetCode Biweekly Contest 4
問題文

問題概要

省略

解法

省略

cLayversion 20190714-1)のコード [C++に変換後]

#include<bits/stdc++.h>
using namespace std;
int cnt[100000];
class Solution{
  public:
  bool canDivideIntoSubsequences(vector<int>& nums, int K){
    int N=nums.size(), i;
    for(i=0;i<100000;i++){
      cnt[i] = 0;
    }
    for(i=0;i<N;i++){
      cnt[nums[i]-1]++;
    }
    for(i=0;i<100000;i++){
      if(cnt[i]*K > N){
        return false;
      }
    }
    return true;
  }
}
;

// cLay varsion 20190714-1

// --- original code ---
// int cnt[1d5];
// 
// class Solution {
// public:
//   bool canDivideIntoSubsequences(vector<int>& nums, int K) {
//     int i, N = nums.size();
//     rep(i,1d5) cnt[i] = 0;
//     rep(i,N) cnt[nums[i]-1]++;
//     rep(i,1d5) if(cnt[i]*K > N) return false;
//     return true;
//   }
// };
// 
// {
//   // main関数を適当に処理する
// }

Current time: 2024年03月29日09時14分34秒
Last modified: 2019年07月14日04時23分48秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: