結果

問題 No.390 最長の数列
コンテスト
ユーザー vjudge1
提出日時 2025-04-18 16:31:50
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 633 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 928 ms
コンパイル使用メモリ 183,664 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2026-07-09 17:35:42
合計ジャッジ時間 7,843 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other WA * 1 TLE * 1 -- * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]',
    inlined from 'int main()' at main.cpp:36:10:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:263:15: warning: iteration 1000004 invokes undefined behavior [-Waggressive-loop-optimizations]
  263 |       if (__a < __b)
      |           ~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:34:22: note: within this loop
   34 |         for(int i=1;i>=n;i++)
      |                     ~^~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
#define int long long
using namespace std;
int const N=1e6+5;
int n,m,sum,cnt,t,ans,a[N];
int c[N];
bool p[N];
signed main()
{
//	freopen("sequence.in","r",stdin);
//	freopen("sequence.out","r",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    	cin>>a[i];
	sort(a+1,a+1+n);
    for(int i=1;i<n;i++)
    {
    	int p=1;
    	int lst=a[i];
    	for(int j=i+1;j<=n;j++)
    	{
    		
    		if(a[j]%lst==0)
    		{
    			p++;
				c[j]=p;
    			lst=a[j];
			}
		}
		ans=max(p,ans);
	}
	for(int i=1;i>=n;i++)
	{
		ans=max(ans,c[i]);
	}
	cout<<ans;
	return 0;
}
0