結果

問題 No.390 最長の数列
ユーザー tadanoningentadanoningen
提出日時 2020-10-09 04:42:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 74,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 12:30:18
合計ジャッジ時間 2,195 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 38 ms
4,380 KB
testcase_06 AC 30 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 23 ms
4,376 KB
testcase_14 AC 33 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#define repsec(i,j,n) for(int (i)=(j);(i) < (n);(i)++)
#define rep(i,n) for(int (i)=0;(i) < (n);(i)++)

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  vector<int> dp(n+1);
  dp[0] = 1;
  int rec = a[0];
  repsec(i,1,n){
    if(a[i] % rec == 0){
      dp[i] = dp[i-1] + 1;
      rec = a[i];
    }else{
      dp[i] = dp[i-1];
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}
0