結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | ngtkana |
提出日時 | 2020-01-30 21:46:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,077 bytes |
コンパイル時間 | 826 ms |
コンパイル使用メモリ | 69,976 KB |
実行使用メモリ | 49,948 KB |
最終ジャッジ日時 | 2023-10-14 08:51:02 |
合計ジャッジ時間 | 3,609 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
25,228 KB |
testcase_01 | AC | 77 ms
25,328 KB |
testcase_02 | AC | 91 ms
23,260 KB |
testcase_03 | WA | - |
testcase_04 | AC | 92 ms
23,352 KB |
testcase_05 | AC | 91 ms
23,444 KB |
testcase_06 | WA | - |
testcase_07 | AC | 93 ms
21,268 KB |
testcase_08 | AC | 93 ms
25,272 KB |
testcase_09 | WA | - |
testcase_10 | AC | 116 ms
23,628 KB |
testcase_11 | AC | 116 ms
25,664 KB |
testcase_12 | WA | - |
testcase_13 | AC | 160 ms
41,060 KB |
testcase_14 | AC | 350 ms
49,948 KB |
testcase_15 | AC | 213 ms
30,420 KB |
ソースコード
using System; using System.Linq; using System.Collections.Generic; public static class Program{ static int ALim=300001; public static void Main() { int n=int.Parse(Console.ReadLine()); int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray(); int[]dp=new int[ALim]; int[]exc=new int[ALim]; for(int i=0;i<ALim;i++)dp[i]=n; for(int i=0;i<n;i++){ Chmin(ref dp[i], a[i]); } int ans=1; while(true){ bool found=false; for(int i=0;i<ALim;i++)exc[i]=n; for(int i=1;i<ALim;i++){ for(int j=2*i;j<ALim;j+=i){ Chmin(ref exc[j], dp[i]); } } for(int i=0;i<ALim;i++)dp[i]=n; for(int i=0;i<n;i++)if(exc[a[i]]<i){ Chmin(ref dp[a[i]],i); found=true; } if(!found)break; ans++; } Console.WriteLine(ans); } public static void Chmin(ref int x, int y){ x=Math.Min(x,y); } }